axtiva / flexible-graphql-federation
Schema SDL first lib for generate php code from graphql sdl to TypeRegistry with webonyx/graphql-php for apollo federation properties
Installs: 4 882
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^7.4 | ^8.0
- axtiva/flexible-graphql-php: ^1.0.3
- axtiva/graphql-federation-extension: ^1.0.1
Requires (Dev)
- phpunit/phpunit: ^9.5
README
Extension for axtiva/flexible-graphql-php for support Apollo Federation in php implementation as SDL first code generation.
Install
composer require axtiva/flexible-graphql-federation
Integration into axtiva/flexible-graphql-php
<?php require_once __DIR__ . '/vendor/autoload.php'; use Axtiva\FlexibleGraphql\Builder\Foundation\CodeGeneratorBuilder; use Axtiva\FlexibleGraphql\Utils\SchemaBuilder; use Axtiva\FlexibleGraphql\Generator\Config\Foundation\Psr4\CodeGeneratorConfig; use Axtiva\FlexibleGraphql\Generator\Config\Foundation\Psr4\FieldResolverGeneratorConfig; use Axtiva\FlexibleGraphql\Federation\Generator\Model\Foundation\Psr4\_EntitiesResolverGenerator; use Axtiva\FlexibleGraphql\Federation\Generator\Model\Foundation\Psr4\_ServiceResolverGenerator; use Axtiva\FlexibleGraphql\Federation\Generator\Config\Foundation\Psr4\FederationRepresentationResolverGeneratorConfig; use Axtiva\FlexibleGraphql\Federation\Generator\model\Foundation\Psr4\FederationRepresentationResolverGenerator; use Axtiva\FlexibleGraphql\FederationExtension\FederationSchemaExtender; $namespace = 'Axtiva\FlexibleGraphql\Example\GraphQL'; $dir = __DIR__ . '/GraphQL'; $mainConfig = new CodeGeneratorConfig($dir, CodeGeneratorConfig::V7_4, $namespace); $builder = new CodeGeneratorBuilder($mainConfig); $fieldResolverConfig = new FieldResolverGeneratorConfig($mainConfig); $representationConfig = new FederationRepresentationResolverGeneratorConfig($mainConfig); $builder->addFieldResolverGenerator(new _EntitiesResolverGenerator($fieldResolverConfig)); $builder->addFieldResolverGenerator(new _ServiceResolverGenerator($fieldResolverConfig)); $builder->addModelGenerator(new FederationRepresentationResolverGenerator($representationConfig)); $generator = $builder->build(); $schema = FederationSchemaExtender::build(SchemaBuilder::build('/path/to/schema.graphql')); foreach ($generator->generateAllTypes($schema) as $filename);