If you want to use GraphQL federation, but you can't rebuild your current GraphQL schema, you can use this transform to add GraphQL federation functionality to an existing schema. You need this when you are using a managed GraphQL service or a generated schema which doesn't support federation (yet).
If you are using apollo-server or another schema builder that supports federation you don't need this transform you should add the federation directives directly.
Check out the blogpost introducing graphql-tranform-federation for more background information.
You can use this transform on a local or a remote GraphQL schema. When using a remote schema your service acts a middleware layer as shown in the diagram above. Check the remote schema documentation for how to get an executable schema that you can use with this transform.
The example below shows a configuration where the transformed schema extends an
existing schema. It already had a resolver
productById which is used to relate
products between the two schemas. This example can be started using
npm run example.
To allow objects of an existing schema to be extended by other schemas it only
needs to get
npm run example
Runs 2 GraphQL servers and a federation gateway to combine both schemas.
Transformed-server is a regular GraphQL
schema that is tranformed using this library. The
federation-server is a federation server which
is extended by a type defined by the
gateway combines both schemas using the apollo gateway.
npm run example:watch
Runs the example in watch mode for development.
npm run test
Run the tests