Recall & Review
beginner
What does it mean to have shared types across subgraphs in GraphQL?
It means that multiple subgraphs use the same type definitions so they can work together smoothly in a federated GraphQL setup.
Click to reveal answer
beginner
Why is sharing types important in a federated GraphQL architecture?
Sharing types ensures consistency and allows different teams to build parts of the graph that fit together without conflicts.
Click to reveal answer
intermediate
How do you mark a type as shared between subgraphs in GraphQL federation?
You use the
@key directive on the type to indicate the fields that uniquely identify it across subgraphs.Click to reveal answer
intermediate
What role does the
@external directive play in shared types?It marks fields that exist in another subgraph but are referenced in the current one, helping to link shared types.
Click to reveal answer
advanced
Can shared types have different fields in different subgraphs?
Yes, subgraphs can extend shared types with additional fields using the
extend type syntax, but the core identity fields must match.Click to reveal answer
What directive is used to specify the unique identifier fields of a shared type in GraphQL federation?
✗ Incorrect
The @key directive defines the fields that uniquely identify a type across subgraphs.
Which directive indicates a field is owned by another subgraph but referenced locally?
✗ Incorrect
The @external directive marks fields that belong to another subgraph.
In a federated schema, how do you add extra fields to a shared type in a subgraph?
✗ Incorrect
You use 'extend type' to add fields to a shared type without redefining it.
Why must shared types have consistent key fields across subgraphs?
✗ Incorrect
Consistent key fields ensure the type can be uniquely identified across all subgraphs.
What happens if two subgraphs define the same type but with different key fields?
✗ Incorrect
Different key fields for the same type cause errors during schema composition.
Explain how shared types work across subgraphs in a federated GraphQL schema.
Think about how types are identified and extended across different parts of the graph.
You got /4 concepts.
Describe the purpose of the @external directive in shared types across subgraphs.
Consider how subgraphs reference fields they don't own.
You got /4 concepts.