Download the PHP package t3n/graphql-apollofederation without Composer
On this page you can find all versions of the php package t3n/graphql-apollofederation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download t3n/graphql-apollofederation
More information about t3n/graphql-apollofederation
Files in t3n/graphql-apollofederation
Package graphql-apollofederation
Short Description Apollo Federation spec implementation for t3n.GraphQL
License
Informations about the package graphql-apollofederation
t3n.GraphQL.ApolloFederation
Sidecar package for t3n.GraphQL to implement the Apollo Federation specification within your GraphQL schema.
Simply install it via composer:
Note: This package is still under progress and might change in it's implementation
About Apollo Federation
Apollo Federation is an architecture for composing multiple GraphQL services into a single graph. This package provides all functionality to implement the specification to your endpoints so you can use your service with Apollo's tools.
Adjustments
In order to implement the specification you need do add some small adjustments to your existing schema. You can see an example implementation here.
Add Federation Spec schema
-
Add the graphql specification to your schema:
-
Add the
ServiceQueryTrait
to your Query-Resolver - Add a new Entity union to your schema:
You need to make each of your entities part of the _Entity
union. In order to do so add
a new schema file to your Endpoint that defines the union:
- Add the EntitiesQueryTrait to your query resolver
This step is optional if do not have any entities.
The Federation specification needs a new query _entities
. Add the trait to all of your QueryResolver:
Also add the _entities
to your query type:
- Implement EntityResolverInterface
Once the _entities
query is called the Entity
union will be resolved. The Apollo Gateway server will send queries like
Depending on the representation input a concrete resolver will be instantiated. All of your Resolvers that resolves
entities must therefore implement the EntityResolverInterface
:
- Implement GraphQLTypeAwareInterface if needed
All of your data that you actually resolve and return which is part of the _Entity
union type must be
aware of it's type name. If it's an object you must implement the GraphQLTypeAwareInterface
. If your data
is an array there must be a key __typename
on the first level.