Schema Contracts enable you to build a multi-purpose, multi-audience graph, which can be split into subsets for different use cases. This simplifies development and keeps your graph maintainable.
tags
and begin delineating the portions of your graph that you wish to keep separate. It’s that easy.
Example of dividing a Composed Schema into two Client Schemas using Schema Contracts
Source Graph
: A federated graph or monograph whose schema is to be filtered out.
Contract Graph / Contract
: A federated graph or monograph that is the filtered version of the source graph.
@tag
directive to detect which schema elements need to be removed. You can apply the directive to objects, interfaces, inputs, types and fields. Here is an example: Consider the below subgraph to be published.
internal
. The composed schema will additionally add the @inaccessible
directive to the field.
wgc contract create
command. You need to supply the list of tags that will be used to perform the filtering of the schema. An example for the above subgraph would be
wgc contract update
command. This will trigger a recomposition of the contract graph and generate new schemas.
Router Schema
: This schema is utilized internally by the router to plan your operations. It encompasses all necessary fields, including ones with @inaccessible as they are still vital for accurate query planning.
Client Schema
: Derived from the Router Schema, this schema excludes elements tagged for removal. It serves as the schema accessible to clients for utilization and is also the one exposed for introspection queries.