Bird
0
0

In GraphQL Playground, what will happen if you run this query?

medium📝 query result Q5 of 15
GraphQL - Basics and Philosophy
In GraphQL Playground, what will happen if you run this query?
query { user(id: "5") { name age } }

Assuming user with id 5 exists and has name and age fields.
AReturns an error because age is not a valid field
BReturns only the id of user 5
CReturns all users with their names and ages
DReturns the name and age of user with id 5
Step-by-Step Solution
Solution:
  1. Step 1: Understand the query request

    The query asks for name and age fields of user with id "5".
  2. Step 2: Confirm user existence and fields

    Since user 5 exists and fields are valid, response includes those fields.
  3. Final Answer:

    Returns the name and age of user with id 5 -> Option D
  4. Quick Check:

    Output = Requested fields for user id 5 [OK]
Quick Trick: Query returns requested fields if user and fields exist [OK]
Common Mistakes:
  • Assuming age field is invalid without checking schema
  • Expecting all users instead of one
  • Thinking only id is returned

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes