What you are building
A feature subgraph is an override of one base subgraph. Here we will use the products subgraph we just created & queried. You will:
- Decide what schema change the feature introduces
- Register a feature subgraph linked to
productswith a separate routing URL - Publish the extended schema
The feature
For our exercise, we'll add one new field to the products service: productCount. This is an Int that tracks how many products are associated with a given employee.
The base products subgraph already contributes product information on Employee. With productCount included:
We won't edit the schema directly for our example. Instead, we'll create the feature subgraph, download the schema, and publish it to Cosmo Cloud.
Create the feature subgraph
Every feature subgraph is linked to the base subgraph it intends to replace. Pass products to --subgraph and point --routing-url at the deployed feature endpoint (fs is the alias for feature-subgraph):
No labels on feature subgraphs
Feature subgraphs do not define labels. Only feature flags define labels, and those labels dictate which supergraph(s) the flag applies to. Our onboarding demo graph has no label matchers, so the flag in the next lesson will not need --label either.
Publish the extended schema
Download the feature schema and publish it with wgc subgraph publish:
No new composition happens yet. A feature subgraph is inert until it is part of an enabled feature flag, so publishing its schema does not yet change what your demo graph serves.
In the next lesson we'll enable our flag on Cosmo Cloud and query our feature subgraph.
Task
Confirm your setup