{"id":14976138,"url":"https://github.com/simpod/graphql-utils","last_synced_at":"2025-08-20T22:32:29.610Z","repository":{"id":30513232,"uuid":"125188043","full_name":"simPod/GraphQL-Utils","owner":"simPod","description":"Set of utilities to power up your development with webonyx/graphql","archived":false,"fork":false,"pushed_at":"2024-11-14T18:07:50.000Z","size":208,"stargazers_count":12,"open_issues_count":1,"forks_count":3,"subscribers_count":5,"default_branch":"0.7.x","last_synced_at":"2024-12-15T04:07:40.460Z","etag":null,"topics":["graphql","graphql-php","graphql-schema","graphql-tools","graphql-utils","php","schema-builder","schema-builders"],"latest_commit_sha":null,"homepage":"https://github.com/webonyx/graphql-php","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simPod.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["simPod"]}},"created_at":"2018-03-14T09:30:14.000Z","updated_at":"2024-11-14T18:07:52.000Z","dependencies_parsed_at":"2024-03-16T10:49:01.856Z","dependency_job_id":"aa87504e-cdd3-4a2a-9d71-ab2da1b4eca0","html_url":"https://github.com/simPod/GraphQL-Utils","commit_stats":{"total_commits":170,"total_committers":5,"mean_commits":34.0,"dds":0.4117647058823529,"last_synced_commit":"6fde9c1d16f320403442e63ec3ce964a8faf265d"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simPod%2FGraphQL-Utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simPod%2FGraphQL-Utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simPod%2FGraphQL-Utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simPod%2FGraphQL-Utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simPod","download_url":"https://codeload.github.com/simPod/GraphQL-Utils/tar.gz/refs/heads/0.7.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230462913,"owners_count":18229865,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graphql","graphql-php","graphql-schema","graphql-tools","graphql-utils","php","schema-builder","schema-builders"],"created_at":"2024-09-24T13:53:22.662Z","updated_at":"2024-12-19T16:12:42.877Z","avatar_url":"https://github.com/simPod.png","language":"PHP","readme":"# PHP GraphQL Utils for graphql-php\n\n[![GitHub Actions][GA Image]][GA Link]\n[![Code Coverage][Coverage Image]][CodeCov Link]\n[![Downloads][Downloads Image]][Packagist Link]\n[![Packagist][Packagist Image]][Packagist Link]\n[![Infection MSI][Infection Image]][Infection Link]\n\n## Installation\n\nAdd as [Composer](https://getcomposer.org/) dependency:\n\n```sh\ncomposer require simpod/graphql-utils\n```\n\n## Features\n\n### Schema Builders\n\nInstead of defining your schema as an array, use can use more objective-oriented approach. This library provides set of strictly typed builders that help you build your schema:\n\n- EnumBuilder\n- FieldBuilder\n- InputFieldBuilder\n- InputObjectBuilder\n- InterfaceBuilder\n- ObjectBuilder\n- TypeBuilder\n- UnionBuilder\n\n#### ObjectBuilder and FieldBuilder\n\n✔️ Standard way with `webonyx/graphql-php`\n\n```php\n\u003c?php\n\nuse GraphQL\\Type\\Definition\\ObjectType;\nuse GraphQL\\Type\\Definition\\ResolveInfo;\n\n$userType = new ObjectType([\n    'name' =\u003e 'User',\n    'description' =\u003e 'Our blog visitor',\n    'fields' =\u003e [\n        'firstName' =\u003e [\n            'type' =\u003e Type::string(),\n            'description' =\u003e 'User first name'\n        ],\n        'email' =\u003e Type::string()\n    ],\n    'resolveField' =\u003e static function(User $user, $args, $context, ResolveInfo $info) {\n        switch ($info-\u003efieldName) {\n            case 'name':\n              return $user-\u003egetName();\n            case 'email':\n              return $user-\u003egetEmail();\n            default:\n              return null;\n        }\n    }\n]);\n``` \n\n✨ The same can be produced in objective way\n\n```php\n\u003c?php\n\nuse GraphQL\\Type\\Definition\\ObjectType;\nuse GraphQL\\Type\\Definition\\ResolveInfo;\nuse SimPod\\GraphQLUtils\\Builder\\ObjectBuilder;\n\n$userType = new ObjectType(\n    ObjectBuilder::create('User')\n        -\u003esetDescription('Our blog visitor')\n        -\u003esetFields([\n            FieldBuilder::create('firstName', Type::string())\n                -\u003esetDescription('User first name')\n                -\u003ebuild(),\n            FieldBuilder::create('email', Type::string())-\u003ebuild(),\n        ])\n        -\u003esetFieldResolver(\n            static function(User $user, $args, $context, ResolveInfo $info) {\n               switch ($info-\u003efieldName) {\n                   case 'name':\n                     return $user-\u003egetName();\n                   case 'email':\n                     return $user-\u003egetEmail();\n                   default:\n                     return null;\n               }\n            }\n        )\n        -\u003ebuild()\n);\n```\n\n#### EnumBuilder\n\n✔️ Standard way with `webonyx/graphql-php`\n\n```php\n\u003c?php\n\nuse GraphQL\\Type\\Definition\\EnumType;\n\n$episodeEnum = new EnumType([\n    'name' =\u003e 'Episode',\n    'description' =\u003e 'One of the films in the Star Wars Trilogy',\n    'values' =\u003e [\n        'NEWHOPE' =\u003e [\n            'value' =\u003e 4,\n            'description' =\u003e 'Released in 1977.'\n        ],\n        'EMPIRE' =\u003e [\n            'value' =\u003e 5,\n            'description' =\u003e 'Released in 1980.'\n        ],\n        'JEDI' =\u003e [\n            'value' =\u003e 6,\n            'description' =\u003e 'Released in 1983.'\n        ],\n    ]\n]);\n```\n\n✨ The same can be produced in objective way\n\n```php\n\u003c?php\n\nuse GraphQL\\Type\\Definition\\EnumType;\nuse SimPod\\GraphQLUtils\\Builder\\EnumBuilder;\n\n$episodeEnum = new EnumType( \n    EnumBuilder::create('Episode')\n        -\u003esetDescription('One of the films in the Star Wars Trilogy')\n        -\u003eaddValue(4, 'NEWHOPE', 'Released in 1977.')\n        -\u003eaddValue(5, 'EMPIRE', 'Released in 1980.')\n        -\u003eaddValue(6, 'JEDI', 'Released in 1983.')\n        -\u003ebuild()\n);\n```\n\n#### InterfaceBuilder\n\n✔️ Standard way with `webonyx/graphql-php`\n\n```php\n\u003c?php\n\nuse GraphQL\\Type\\Definition\\InterfaceType;\nuse GraphQL\\Type\\Definition\\Type;\n\n$character = new InterfaceType([\n    'name' =\u003e 'Character',\n    'description' =\u003e 'A character in the Star Wars Trilogy',\n    'fields' =\u003e [\n        'id' =\u003e [\n            'type' =\u003e Type::nonNull(Type::string()),\n            'description' =\u003e 'The id of the character.',\n        ],\n        'name' =\u003e [\n            'type' =\u003e Type::string(),\n            'description' =\u003e 'The name of the character.'\n        ]\n    ],\n    'resolveType' =\u003e static function ($value) : object {\n        if ($value-\u003etype === 'human') {\n            return MyTypes::human();            \n        }\n\n        return MyTypes::droid();\n    }\n]);\n```\n\n✨ The same can be produced in objective way\n\n```php\n\u003c?php\n\nuse GraphQL\\Type\\Definition\\InterfaceType;\nuse GraphQL\\Type\\Definition\\Type;\nuse SimPod\\GraphQLUtils\\Builder\\InterfaceBuilder;\nuse SimPod\\GraphQLUtils\\Builder\\FieldBuilder;\n\n$character = new InterfaceType(\n    InterfaceBuilder::create('Character')\n        -\u003esetDescription('A character in the Star Wars Trilogy')\n        -\u003esetFields([\n            FieldBuilder::create('id', Type::nonNull(Type::string()))\n                -\u003esetDescription('The id of the character.')\n                -\u003ebuild(),\n            FieldBuilder::create('name', Type::string())\n                -\u003esetDescription('The name of the character.')\n                -\u003ebuild()\n        ])\n        -\u003esetResolveType(\n            static function ($value) : object {\n                if ($value-\u003etype === 'human') {\n                    return MyTypes::human();            \n                }\n    \n                return MyTypes::droid();\n            }\n        )\n        -\u003ebuild()\n);\n```\n\n#### UnionBuilder\n\n✔️ Standard way with `webonyx/graphql-php`\n\n```php\n\u003c?php\n\nuse GraphQL\\Type\\Definition\\UnionType;\n\n$searchResultType = new UnionType([\n    'name' =\u003e 'SearchResult',\n    'types' =\u003e [\n        MyTypes::story(),\n        MyTypes::user()\n    ],\n    'resolveType' =\u003e static function($value) {\n        if ($value-\u003etype === 'story') {\n            return MyTypes::story();            \n        }\n\n        return MyTypes::user();\n    }\n]);\n```\n\n✨ The same can be produced in objective way\n\n```php\n\u003c?php\n\nuse SimPod\\GraphQLUtils\\Builder\\UnionBuilder;\n\n$character = new UnionType(\n    UnionBuilder::create(\n        'SearchResult',\n        [\n            MyTypes::story(),\n            MyTypes::user()\n        ]\n    )\n        -\u003esetResolveType(\n            static function($value) {\n                if ($value-\u003etype === 'story') {\n                    return MyTypes::story();            \n                }\n        \n                return MyTypes::user();\n            }\n        )\n        -\u003ebuild()\n);\n```\n\n[GA Image]: https://github.com/simPod/GraphQL-Utils/workflows/CI/badge.svg\n\n[GA Link]: https://github.com/simPod/GraphQL-Utils/actions?query=workflow%3A%22CI%22+branch%3A0.7.x\n\n[Coverage Image]: https://codecov.io/gh/simPod/GraphQL-Utils/branch/0.7.x/graph/badge.svg\n\n[CodeCov Link]: https://codecov.io/gh/simPod/GraphQL-Utils/branch/0.7.x\n\n[Downloads Image]: https://poser.pugx.org/simpod/graphql-utils/d/total.svg\n\n[Packagist Image]: https://poser.pugx.org/simpod/graphql-utils/v/stable.svg\n\n[Packagist Link]: https://packagist.org/packages/simpod/graphql-utils\n\n[Infection Image]: https://img.shields.io/endpoint?style=flat\u0026url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2FsimPod%2FGraphQL-Utils%2F0.7.x\n\n[Infection Link]: https://dashboard.stryker-mutator.io/reports/github.com/simPod/GraphQL-Utils/0.7.x\n","funding_links":["https://github.com/sponsors/simPod"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimpod%2Fgraphql-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimpod%2Fgraphql-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimpod%2Fgraphql-utils/lists"}