0
0
GraphQLquery~20 mins

Why federation scales GraphQL - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Federation Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why does federation improve GraphQL scalability?
Which of the following best explains why federation helps GraphQL scale better?
AIt splits a large GraphQL schema into smaller services, allowing independent development and scaling.
BIt caches all GraphQL queries on the client side to reduce server load.
CIt merges all backend databases into one to simplify data retrieval.
DIt converts GraphQL queries into SQL queries automatically for faster database access.
Attempts:
2 left
💡 Hint
Think about how dividing work among smaller parts can help handle more requests.
query_result
intermediate
2:00remaining
Result of federated GraphQL query
Given two federated services: Users and Products, what will be the result of this query? { user(id: "1") { name purchasedProducts { name } } } Assuming user 1 has purchased two products: 'Book' and 'Pen'.
A{ "data": { "user": { "name": "Alice", "purchasedProducts": null } } }
B{ "data": { "user": { "name": "Alice", "purchasedProducts": [{ "name": "Book" }, { "name": "Pen" }] } } }
C{ "errors": [{ "message": "Field 'purchasedProducts' not found" }] }
D{ "data": { "user": null } }
Attempts:
2 left
💡 Hint
Federation allows combining data from multiple services in one query.
📝 Syntax
advanced
2:00remaining
Identify the syntax error in this federation SDL
Which option contains the correct syntax for extending a type in a federated GraphQL schema? Given this partial schema: extend type Product @key(fields: "id") { id: ID! @external price: Float } Which option fixes the syntax error?
A
extend type Product @key(fields: "id") {
  id: ID @external
  price: Float
}
B
extend type Product @key(fields: id) {
  id: ID! @external
  price: Float
}
C
extend type Product @key(fields: "id") {
  id: ID! @external
  price: Float
}
D
extend Product type @key(fields: "id") {
  id: ID! @external
  price: Float
}
Attempts:
2 left
💡 Hint
Look carefully at the placement of keywords and quotes.
optimization
advanced
2:00remaining
Optimizing federated GraphQL queries
Which approach best optimizes performance in a federated GraphQL setup when multiple services are involved?
ABatch requests to services and minimize nested queries to reduce network overhead.
BUse only one service to handle all queries to avoid federation complexity.
CSend separate queries to each service for every client request to ensure fresh data.
DDisable caching to always get the latest data from each service.
Attempts:
2 left
💡 Hint
Think about reducing the number of network calls and data fetching.
🔧 Debug
expert
3:00remaining
Debugging a federation key mismatch error
You have two federated services: Users and Orders. Users service defines: type User @key(fields: "id") { id: ID! name: String } Orders service defines: type User @key(fields: "userId") { userId: ID! orders: [Order] } When querying user orders, you get an error about key mismatch. What is the cause?
AThe Orders service is missing the @external directive on 'userId'.
BThe Orders service must use 'id' as the field name instead of 'userId' without changing the key.
CThe User type must not be defined in more than one service.
DThe key fields differ between services: 'id' vs 'userId', causing federation to fail to match entities.
Attempts:
2 left
💡 Hint
Check if the key fields used to identify the same type are consistent across services.