The term schema stitching refers to the act of combining (at least) two GraphQL schemas into a single one. There are several use cases and different scenarios for how exactly schema stitching might take place. In the following, a number of different scenarios are described and how they can be solved with the available tooling.
Merging two (or more) schemas means forming the union of their respective types. If there are naming conflicts between types of the merged schemas, additional information needs to be provided to determine how these conflicts should be resolved.
graphql-tools provides an API for merging schemas:
There are four examples explaining different use cases for schema merging:
- Merging schemas without naming conflicts
- Merging schemas with naming conflicts on their root fields
- Merging schemas with naming conflicts for types
- Merging an executable with a non-executable schema
Picking parts of a schema
Another use case for schema stitching is when only certain parts of a schema are selectively added to another schema. This feature is currently still experimental - a first API for it is available here.