axtiva / flexible-graphql-php
Schema SDL first lib for generate php code from graphql sdl to TypeRegistry with webonyx/graphql-php
Requires
- php: ^8.3
- nikic/php-parser: ^5
- webonyx/graphql-php: ^15.30
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^12
- psr/container: ^1 | ^2
- dev-master
- v3.0.1
- v3.0.0
- 2.x-dev
- v2.2.0
- v2.1.3
- v2.1.2
- v2.1.1
- v2.1.1-rc1
- v2.1.0
- v2.0.0
- v2.0.0-alpha
- 1.x-dev
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- v0.2.3
- v0.2.2
- v0.2.1
- v0.2.0
- v0.1.1
- v0.1.0
- dev-fix(bug)-generator-of-inputobject-missmatch-interface
- dev-upgrade-php
- dev-2026-03-13_08-20_restore-precise-resolver-typing
- dev-2026-03-13_07-18_refactor-generated-tests-php-fixtures
- dev-2026-03-13_06-10_phpstan6-src-example-templates
- dev-2026-03-13_02-10_phpstan9-no-ignores-generated-code
- dev-2026-03-13_00-55_remove-phpstan-baseline-level-9
- dev-2026-03-13_00-04_phpstan9-php83-85-ci-coverage
- dev-2026-03-12_22-52_php83-codegen-modernize-ci
- dev-add_some_tests_for_federation
This package is auto-updated.
Last update: 2026-03-13 22:07:41 UTC
README
Schema first lib for generate php code from graphql sdl to TypeRegistry whom support webonyx/graphql-php with simple integrate to any controller.
TL;DR
Can easy to integrate graphql to any project, all you need is controller. Fast start with example
Features:
- Schema/SDL first code generation (look at example dir)
- Support all features from webonyx/graphql-php
- Executable directives
- Apollo Federation/Federation2 support
- Popular framework integration:
- Symfony axtiva/flexible-graphql-bundle
Setup
Composer install:
composer require axtiva/flexible-graphql-php
Examples:
- Generate models by types in Graphql Schema example/generate_type_models.php
- Generate custom scalar resolver by Graphql Schema example/generate_scalar_resolver.php
- Generate directive resolver by Graphql Schema example/generate_directive_resolver.php
- Generate type field resolver by Graphql Schema example/generate_field_resolver.php
- Create lazy loaded TypeRegistry example/generate_type_registry.php
- Setup graphql request handler with lazy loaded TypeRegistry example/start_graphql_server.php
Demo
Up Dev server for test http Graphql requests:
php -S localhost:8080 example/start_graphql_server.php
Change schema and run example commands
Update TypeRegistry and model classes from schema and resolvers map:
php example/generate_code.php
If you need to make field resolver, then remove AutoGenerationInterface from model CodedCurrencyType
Example:
- final class CodedCurrencyType implements AutoGenerationInterface, NodeInterface, CurrencyInterface + final class CodedCurrencyType implements NodeInterface, CurrencyInterface { public string $id; - public int $code; }
and run php example/generate_code.php, after this you will find in example/Resolver/CodedCurrency/CodeResolver.php.
this is your field resolver, define him in your psr container like PsrContainerExample in example/start_graphql_server.php:
$container = new PsrContainerExample([
\Axtiva\FlexibleGraphql\Example\GraphQL\Resolver\Query\AccountResolver::class =>
new \Axtiva\FlexibleGraphql\Example\GraphQL\Resolver\Query\AccountResolver,
+ \Axtiva\FlexibleGraphql\Example\GraphQL\Resolver\CodedCurrency\CodeResolver::class =>
+ new \Axtiva\FlexibleGraphql\Example\GraphQL\Resolver\CodedCurrency\CodeResolver,
]);
Run demo app php -S localhost:8080 example/start_graphql_server.php and try request CodedCurrency.code field in query
Tests
Run tests
php vendor/bin/phpunit
PHPStan
Run PHPStan
php vendor/bin/phpstan analyse -c phpstan.neon