Challenge - 5 Problems
GraphQL vs REST Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Key difference in data fetching between GraphQL and REST
Which statement best describes how GraphQL differs from REST in fetching data?
Attempts:
2 left
💡 Hint
Think about how many requests are needed to get related data in each approach.
✗ Incorrect
GraphQL lets clients specify exactly what data they want in one request, reducing over-fetching and under-fetching. REST typically uses multiple endpoints, which may require several requests.
🧠 Conceptual
intermediate2:00remaining
Handling versioning in GraphQL vs REST
How is API versioning typically handled differently in GraphQL compared to REST?
Attempts:
2 left
💡 Hint
Consider how clients adapt to changes in each API style.
✗ Incorrect
REST APIs often use version numbers in URLs to manage changes. GraphQL encourages evolving the schema by adding new fields and deprecating old ones without versioning.
❓ query_result
advanced2:00remaining
GraphQL query result shape
Given this GraphQL query:
What is the expected shape of the JSON response?
{ user(id: "1") { name, posts { title } } }What is the expected shape of the JSON response?
Attempts:
2 left
💡 Hint
GraphQL responses always wrap data inside a 'data' key.
✗ Incorrect
GraphQL responses wrap the requested data inside a 'data' object. The shape matches the query structure exactly.
📝 Syntax
advanced2:00remaining
Identify the syntax error in this GraphQL query
Which option contains a syntax error in the GraphQL query?
GraphQL
query { user(id: "1") { name posts { title } } }Attempts:
2 left
💡 Hint
Look for missing commas between fields.
✗ Incorrect
GraphQL requires commas between fields in selection sets. Missing commas cause syntax errors.
❓ optimization
expert3:00remaining
Optimizing REST API calls compared to GraphQL
You have a REST API with endpoints /users and /posts. To get a user's name and their posts' titles, you must call both endpoints. How does GraphQL optimize this scenario?
Attempts:
2 left
💡 Hint
Think about how many requests are needed in REST vs GraphQL for related data.
✗ Incorrect
GraphQL lets clients request related data in one query, reducing the number of network calls compared to REST which requires multiple endpoints.