worksome/graphql-helpers

This is my package graphql-helpers
350,378 2
Install
composer require worksome/graphql-helpers
Latest Version:v0.1.19
PHP:^8.4
Laravel:12 · 13
Older releases:9 · 10 · 11
License:MIT
Last Updated:Oct 16, 2026
Links: GitHub  ·  Packagist
Maintainer: owenvoke

PHP GraphQL Helpers

Latest Version on Packagist GitHub Tests Action Status GitHub Static Analysis Action Status Total Downloads

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);

The PhpEnumType class will automatically use the description from the GraphQL\Type\Definition\Description attribute if it is present.

The CasesDescribedBy attribute

If you require the use of a custom method to retrieve the description, you can use the #[CasesDescribedBy] attribute.

#[\Worksome\GraphQLHelpers\Definition\Attributes\CasesDescribedBy(describer: 'description')]
enum MyEnum
{
    case CaseOne;

    public function description(): string
    {
        return 'The First Case!';
    }
}

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.

Related Packages

worksome/envy

Automatically keep your .env files in sync.

2,075,809 688
worksome/exchange

Check Exchange Rates for any currency in Laravel.

681,882 126
worksome/company-info

Lookup company information

522,301 34
worksome/request-factories

Test Form Requests in Laravel without all of the boilerplate.

2,340,626 622
worksome/verify-by-phone

Verify your users by call or SMS

661,040 147

Version History

Version Released PHP Laravel License
v0.1.19 ^8.4 ^12.0|^13.0 MIT
v0.1.18 ^8.4 ^11.0 || ^12.0 || ^13.0 MIT
v0.1.17 ^8.4 ^11.0 || ^12.0 MIT
v0.1.16 ^8.3 ^11.0 || ^12.0 MIT
v0.1.15 ^8.3 ^11.0 || ^12.0 MIT