0
0
GraphQLquery~5 mins

Subgraph definition in GraphQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a subgraph in GraphQL?
A subgraph is a smaller part of a larger GraphQL graph. It defines a set of types and fields that focus on a specific domain or service.
Click to reveal answer
beginner
What does a subgraph definition usually include?
It includes the schema with types, queries, mutations, and sometimes directives that describe the data and operations for that subgraph.
Click to reveal answer
intermediate
Why do we use subgraphs in a GraphQL architecture?
Subgraphs help split a big graph into smaller, manageable parts. This makes development easier and allows teams to work independently on different domains.
Click to reveal answer
intermediate
How does a subgraph relate to a federated GraphQL gateway?
A federated gateway combines multiple subgraphs into one unified graph. Each subgraph provides part of the overall schema that the gateway merges.
Click to reveal answer
advanced
What is the role of the @key directive in a subgraph definition?
The @key directive marks a field or set of fields as a unique identifier for an entity. It helps the gateway know how to reference and join data across subgraphs.
Click to reveal answer
What does a subgraph in GraphQL represent?
AA database table
BA frontend UI component
CA part of the overall graph focusing on a specific domain
DA GraphQL query operation
Which directive is commonly used in subgraph definitions to identify entities uniquely?
A@key
B@entity
C@unique
D@id
What is the main purpose of splitting a GraphQL schema into subgraphs?
ATo allow multiple teams to work independently on different parts
BTo reduce the number of queries sent
CTo improve query speed by caching
DTo avoid using GraphQL federation
In a federated GraphQL setup, what combines the subgraphs into one schema?
AGraphQL client
BFederated gateway
CDatabase engine
DGraphQL server
Which of the following is NOT typically part of a subgraph definition?
ADirectives
BResolvers
CType definitions
DUI components
Explain what a subgraph definition is and why it is useful in GraphQL.
Think about how big projects can be divided into smaller pieces.
You got /4 concepts.
    Describe the role of the @key directive in a subgraph definition and how it helps federation.
    Focus on how different subgraphs connect their data.
    You got /3 concepts.