How It Works¶
Setting up Fusion for a composite schema is relatively straightforward, specially by using the capabilities the Suite CLI provides us.
Configuring subgraphs¶
As it was previously stated, subgraphs are exposed by backend services as standalone, business-oriented schemas. Nonetheless, if we require to expose our source schema to a gateway we need to do some configuration.
Lets start by referencing our gateway from the backend service's
application.yaml
| application.yaml | |
|---|---|
This is enough for the suite tooling to discover and understand the relation between our subgraph and the specified gateway. Note that we can optionally specify extension files that will be only applied for that gateway, and multiple gateways can be specified as well.
From HotChocolate's perspective, we need to make our subgraph discoverable; this means giving it a well-known name and an address where we can reach it.
| subgraph-config.json | |
|---|---|
Exposing source schemas¶
Each subgraph's schema is exposed through a schema.graphql file. This is also
easily generated by the suite CLI.
| Bash | |
|---|---|
Running this command will actually do two things:
- Generate the source schema file from the application's runtime.
- Pack the subgraph for each gateway specified in the
application.yamlfile, including each extension files if any.
If we only want to generate our source schema without packing (this can be helpful specially during development time) we can do so by run ing
| Bash | |
|---|---|
Composing the gateway schema¶
Source schemas can be composed for each gateway by running
| Bash | |
|---|---|
The suite CLI once again targets all gateways that should be composed based on
the application.yaml data and generates the composed gateway files.