Bird
0
0

What will be the result of this query?

medium📝 query result Q5 of 15
GraphQL - Basics and Philosophy
What will be the result of this query?
query { user { id name age } }

If the server has a user with id=1, name='Anna', and age=30?
A{"data": {"user": {"id": 1, "name": "Anna"}}}
B{"data": {"user": null}}
C{"error": "Field age not found"}
D{"data": {"user": {"id": 1, "name": "Anna", "age": 30}}}
Step-by-Step Solution
Solution:
  1. Step 1: Check requested fields and server data

    The query requests id, name, and age. The server has all these fields for the user.
  2. Step 2: Predict the server response format

    The server returns a JSON object with data matching the query fields and values.
  3. Final Answer:

    {"data": {"user": {"id": 1, "name": "Anna", "age": 30}}} -> Option D
  4. Quick Check:

    Query fields match response fields [OK]
Quick Trick: Response JSON matches query fields exactly [OK]
Common Mistakes:
  • Missing fields in response
  • Expecting error without reason
  • Null data when user exists

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes