Challenge - 5 Problems
Apollo Federation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
What is the primary purpose of Apollo Federation?
Apollo Federation allows multiple GraphQL services to work together as one. What is its main goal?
Attempts:
2 left
💡 Hint
Think about how multiple teams can build parts of a graph independently.
✗ Incorrect
Apollo Federation's main purpose is to let different teams build separate GraphQL services that combine into one unified graph for clients.
❓ query_result
intermediate2:00remaining
What is the output of this federated query?
Given two services: Product service with type Product { id, name } and Review service extending Product with { reviews }, what is the result of querying { product(id: "1") { id name reviews { body } } }?
GraphQL
query {
product(id: "1") {
id
name
reviews {
body
}
}
}Attempts:
2 left
💡 Hint
Remember that Review service extends Product to add reviews.
✗ Incorrect
The Review service extends Product to add reviews, so querying reviews on product returns the reviews data.
📝 Syntax
advanced2:00remaining
Which SDL snippet correctly defines an entity in Apollo Federation?
Choose the correct way to define a Product entity with a key field 'id' in Apollo Federation SDL.
GraphQL
type Product {
id: ID!
name: String
}Attempts:
2 left
💡 Hint
The @key directive marks the primary key field for the entity.
✗ Incorrect
In Apollo Federation, @key(fields: "id") on the type defines the entity's primary key. The syntax must be exact.
❓ optimization
advanced2:00remaining
How does Apollo Gateway optimize resolving entities across services?
Apollo Gateway receives a query that requires data from multiple services. How does it optimize fetching entities?
Attempts:
2 left
💡 Hint
Think about how to reduce repeated calls for the same entity.
✗ Incorrect
Apollo Gateway batches entity requests by keys so it can fetch multiple entities in one call to each subgraph, reducing network overhead.
🔧 Debug
expert3:00remaining
Why does this federated query fail with an error?
Given two services: User service defines type User @key(fields: "id") { id: ID! name: String }, and Order service extends User with extend type User @key(fields: "id") { id: ID! orders: [Order] }, a query requests user { id name orders { id } }. The error says: "Cannot query field 'orders' on type 'User'". What is the cause?
Attempts:
2 left
💡 Hint
Check how the User type is extended and if the gateway schema includes the extension.
✗ Incorrect
If the Order service does not properly extend User with the @key directive and matching fields, the gateway won't merge the 'orders' field into the User type, causing the query error.