worksome / graphql-helpers
This is my package graphql-helpers
Fund package maintenance!
worksome
Installs: 204 401
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 12
Forks: 0
Open Issues: 0
Requires
- php: ^8.3
- illuminate/support: ^11.0 || ^12.0
- jawira/case-converter: ^3.5
- webonyx/graphql-php: ^15.19
Requires (Dev)
- larastan/larastan: ^3.1
- nunomaduro/collision: ^7.10 || ^8.1.1
- orchestra/testbench: ^9.12 || ^10.1
- pestphp/pest: ^3.7
- pestphp/pest-plugin-laravel: ^3.1
- worksome/coding-style: ^3.2
README
A collection of GraphQL helpers for GraphQL PHP.
Installation
You can install the package via composer:
composer require worksome/graphql-helpers
Usage
Enum Type Registration
The PhpEnumType
class can be used to override the GraphQL\Type\Definition\EnumType
class with automatic case conversion.
enum MyEnum { case CaseOne; } new \Worksome\GraphQLHelpers\Definition\PhpEnumType(MyEnum::class);
Enum Concerns
GraphQLConvertable
The GraphQLConvertable
concern is used to easily convert an enum instance to its GraphQL value within your codebase.
enum MyEnum { use \Worksome\GraphQLHelpers\Definition\Concerns\GraphQLConvertable; case CaseOne; } MyEnum::CaseOne->toGraphQLValue(); // CASE_ONE
GraphQLDescribable
The GraphQLDescribable
concern is used to easily retrieve the description of an enum instance using the value from a GraphQL\Type\Definition\Description
attribute.
enum MyEnum { use \Worksome\GraphQLHelpers\Definition\Concerns\GraphQLDescribable; #[\GraphQL\Type\Definition\Description('The First Case!')] case CaseOne; } MyEnum::CaseOne->description(); // The First Case!
Testing Enums
The HandlesEnumConversions
concern adds support for quickly converting an enum to its GraphQL value.
enum MyEnum { case CaseOne; } // In Pest uses(\Worksome\GraphQLHelpers\Testing\Concerns\HandlesEnumConversions::class); $this->enumToGraphQL(MyEnum::CaseOne); // CASE_ONE
Testing
composer test
Changelog
Please see GitHub Releases for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.