Skip to content

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
1
2
3
4
5
6
7
8
spec:
    build:
        dotnet:
            graphql:
                publish:
                    - gateway: admin-center-bff
                      extensions:
                          - admin-center.fusion.extensions.graphql

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
1
2
3
4
{
    "subgraph": "addresses",
    "http": { "baseAddress": "http://addresses-service/graphql" }
}

Hint

subgraph-config.json can be generated by the suite CLI

Bash
suite app graphql config addresses

Exposing source schemas

Each subgraph's schema is exposed through a schema.graphql file. This is also easily generated by the suite CLI.

Bash
suite app graphql schema addresses

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.yaml file, 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
suite app graphql schema addresses --no-pack

Composing the gateway schema

Source schemas can be composed for each gateway by running

Bash
suite app graphql compose addresses

The suite CLI once again targets all gateways that should be composed based on the application.yaml data and generates the composed gateway files.