x-graphql / schema-transformer
Transforming types, fields of GraphQL schema
Installs: 9 939
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Requires
- php: >=8.2
- webonyx/graphql-php: ^15.9
- x-graphql/delegate-execution: ^0.9
- x-graphql/schema-cache: ^0.1.0
- x-graphql/utils: >=0.2.0
Requires (Dev)
- nyholm/psr7: ^1.8
- phpunit/phpunit: ^11.0
- symfony/cache: ^6.3 || ^7.0
- symfony/http-client: ^6.3 || ^7.0
- symplify/easy-coding-standard: ^12.1
- x-graphql/http-schema: ^0.8
README
Transform SDL and enhance execution query of GraphQL schema
Getting Started
Install this package via Composer
composer require x-graphql/schema-transformer
Usages
use GraphQL\GraphQL; use GraphQL\Utils\SchemaPrinter; use XGraphQL\HttpSchema\HttpDelegator; use XGraphQL\HttpSchema\HttpSchemaFactory; use XGraphQL\SchemaTransformer\AST\PrefixRootFieldsNameTransformer; use XGraphQL\SchemaTransformer\SchemaTransformer; $delegator = new HttpDelegator('https://countries.trevorblades.com/'); $schema = HttpSchemaFactory::createFromIntrospectionQuery($delegator); $transformedSchema = SchemaTransformer::transform( $schema, [ new PrefixRootFieldsNameTransformer('XGraphQL_'), ], ); $query = <<<'GQL' query getCountries { XGraphQL_countries { name } } GQL; var_dump(SchemaPrinter::doPrint($transformedSchema)); $result = GraphQL::executeQuery($transformedSchema, $query); var_dump($result->data);
Credits
Created by Minh Vuong