Skip to main content

Subgraph object

The subgraph object is the core of the composition library. It has the following form:
A DocumentNode can be created using the graphql libary parse function. A simple example subgraph is provided below :

Federating subgraphs

Producing a federating graph with WunderMerge.

federateSubgraphs

The federateSubgraphs function is responsible for normalizing, validating, and finally federating an array of Subgraph objects:

Federation Result

The federateSubgraphs function returns a FederationResult, which has the following form:

Properties

errors: An optional array of all errors encountered during normalization and validation of the subgraph, or composition and validation of the federated graph. If there are any errors during normalization, federation will not be attempted. If federation was successful, the array will be undefined. federatedGraphAST: An optional graphql DocumentNode representation of the federated graph. If federation was unsuccessful, this property will be undefined. federatedGraphSchema: An optional graphql GraphQLSchema representation of the federated graph. If federation was unsuccessful, this property will be undefined.

Printing the federated schema

You can produce a string of the federated graph through graphql print or graphql printSchema.

Example

An example of federation with two graphs.