Bird
0
0

What will be the result of this query?

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

Assuming the 'age' field does not exist in the schema.
AReturns an error about the unknown field 'age'
BReturns id and name, ignores age silently
CReturns id and name, and null for age
DReturns all fields including age with default value 0
Step-by-Step Solution
Solution:
  1. Step 1: Check schema field existence

    'age' is not defined in the schema for 'user'.
  2. Step 2: Understand GraphQL validation

    GraphQL returns an error if a requested field does not exist in the schema.
  3. Final Answer:

    Returns an error about the unknown field 'age' -> Option A
  4. Quick Check:

    Requesting unknown fields causes error = Returns an error about the unknown field 'age' [OK]
Quick Trick: All requested fields must exist in schema [OK]
Common Mistakes:
  • Expecting silent ignore
  • Assuming null is returned
  • Thinking default values are used

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes