0
0
GraphQLquery~5 mins

Shared types across subgraphs in GraphQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
A@share
B@external
C@unique
D@key
Which directive indicates a field is owned by another subgraph but referenced locally?
A@share
B@import
C@external
D@local
In a federated schema, how do you add extra fields to a shared type in a subgraph?
ARedefine the type completely
BUse extend type
CUse @external directive
DUse @key directive
Why must shared types have consistent key fields across subgraphs?
ATo ensure unique identification across subgraphs
BTo avoid naming conflicts
CTo improve query speed
DTo allow different data types
What happens if two subgraphs define the same type but with different key fields?
AIt causes a schema composition error
BThe gateway merges them automatically
CThe last subgraph overrides the first
DThey become separate types
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.