0
0
GraphQLquery~5 mins

Entity references in GraphQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is an entity reference in GraphQL?
An entity reference is a way to uniquely identify an object across services in a federated GraphQL setup, allowing different services to share and resolve the same entity.
Click to reveal answer
beginner
How do you mark a type as an entity in GraphQL federation?
You add the @key directive to the type, specifying one or more fields that uniquely identify the entity.
Click to reveal answer
intermediate
What is the purpose of the _entities field in a federated GraphQL schema?
The _entities field allows querying multiple entities by their references, resolving them to their full data from the appropriate service.
Click to reveal answer
intermediate
Explain how entity references help in a microservices architecture using GraphQL.
Entity references let different microservices own parts of the data but still link and fetch complete entities by their unique keys, enabling a unified API.
Click to reveal answer
beginner
What directive is used to specify the fields that form the unique key for an entity?
The @key directive is used to specify the unique identifying fields of an entity in GraphQL federation.
Click to reveal answer
Which directive marks a GraphQL type as an entity for federation?
A@key
B@entity
C@reference
D@unique
What is the purpose of the _entities field in a federated GraphQL schema?
ATo query multiple entities by their references
BTo list all types in the schema
CTo define new types
DTo delete entities
In GraphQL federation, what does an entity reference usually contain?
AThe entire entity data
BThe unique key fields of the entity
COnly the entity's type name
DThe service URL
Why are entity references important in a microservices GraphQL architecture?
AThey encrypt data between services
BThey speed up database queries
CThey allow services to share and resolve the same entity data
DThey replace REST APIs
Which of the following is NOT true about entity references?
AThey rely on the @key directive
BThey are used to fetch full entity data
CThey uniquely identify an entity across services
DThey store the entire entity data locally
Describe what an entity reference is and how it works in GraphQL federation.
Think about how different services share data about the same object.
You got /4 concepts.
    Explain why entity references are useful in a microservices environment using GraphQL.
    Consider how multiple teams manage parts of data but want a single API.
    You got /4 concepts.