Skip to content

MindgramGit/php-graphql-federation

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GraphQL Federation for PHP

Utility for creating GraphQL microservices, which can be combined into a single endpoint through tools like Apollo Gateway.

Build Status

Installation

Use the package manager composer to install graphql-federation.

composer require pascaldevink/graphql-federation

Usage

Assuming you already have an existing GraphQL implementation using webonyx/graphql-php, these commands add federation:

# First, build your existing schema
$existingSchema = BuildSchema::build(file_get_contents(__DIR__ . '/schema.graphqls'));

# Then, extend it with Federation
$federation = new \PascalDeVink\GraphQLFederation\Federation();
$schema = $federation->extendSchema($existingSchema);

# Build your root value resolver
$rootValue = include __DIR__ . '/rootvalue.php';

# And extend it with Federation resolvers
$rootValue = $federation->addResolversToRootValue($rootValue);

# Finally, execute the query
GraphQL::executeQuery($schema, $query, $rootValue, null, $variableValues);

See the example of webonyx/graphql-php for the rest of the code to make it work.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

About

Utility for creating GraphQL microservices, which can be combined into a single endpoint through tools like Apollo Gateway

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%