0
0
GraphQLquery~10 mins

Why federation scales GraphQL - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a federated service with a key directive.

GraphQL
type Product @key(fields: "[1]") { id: ID! name: String }
Drag options to blanks, or click blank then click option'
Aprice
Bsku
Cid
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-unique field like 'name' as the key.
Omitting the @key directive entirely.
2fill in blank
medium

Complete the code to extend a type from another service in federation.

GraphQL
extend type User @key(fields: "[1]") { id: ID! username: String }
Drag options to blanks, or click blank then click option'
Aid
Bprofile
Cemail
Dusername
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-key field like 'username' in the @key directive.
Forgetting to use the extend keyword.
3fill in blank
hard

Fix the error in the federation SDL by completing the missing directive.

GraphQL
type Review { id: ID! body: String author: User [1] }
Drag options to blanks, or click blank then click option'
A@external
B@provides
C@requires
D@key
Attempts:
3 left
💡 Hint
Common Mistakes
Using @key on a field that is not a key.
Using @provides or @requires incorrectly.
4fill in blank
hard

Fill both blanks to complete the resolver that fetches a federated entity by its key.

GraphQL
User: { __resolveReference([1]) { return fetchUserById([1].[2]); } }
Drag options to blanks, or click blank then click option'
Aid
Buser
Dusername
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong argument name in the resolver.
Using a non-key field to fetch the entity.
5fill in blank
hard

Fill all three blanks to complete the federated schema with multiple services.

GraphQL
schema { query: [1] } type [2] { products: [Product] } type Product @key(fields: "[3]") { id: ID! name: String }
Drag options to blanks, or click blank then click option'
AQuery
BProduct
Cid
DMutation
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Mutation' instead of 'Query' as the root type.
Using 'Product' as the root query type name.
Using a non-key field in the @key directive.