Apollo Federation lets you declaratively combine multiple GraphQL APIs into a single, federated graph. This federated graph enables clients to interact with multiple APIs through a single request.
GQLoom Federation provides GQLoom support for Apollo Federation.
Apollo Federation Directives is used to describe how to combine multiple GraphQL APIs into a federated graph.
In GQLoom, we can declare GraphQL directives in the directives
field of the extensions
property of objects and fields:
In the above example, we have declared a @key
directive which marks the id
field of the User
object as a resolvable field and we will get the following Schema:
We have two formats for declaring instructions:
@gqloom/apollo
provides the resolveReference
function to help you resolve references.
The FederatedSchemaWeaver.weave
function, introduced from @gqloom/federation
, is used to weave Federation Schema. compared to @gqloom/core
, the FederatedSchemaWeaver.weave
function in @gqloom/apollo
will output Schema with Directives.
It is also worth noting that we need to use the printSubgraphSchema
function imported from @apollo/subgraph
to convert the Schema to a textual format in order to preserve the Directives.