Bird
0
0

Why does this GraphQL query fail? Query requests 'user { age }' but server returns error 'Field "age" not found'.

medium📝 Debug Q7 of 15
Rest API - REST API Fundamentals
Why does this GraphQL query fail? Query requests 'user { age }' but server returns error 'Field "age" not found'.
AThe 'age' field is not defined in the GraphQL schema for 'user'
BGraphQL does not support querying numeric fields
CThe query must include 'id' field to work
DGraphQL requires all fields to be strings
Step-by-Step Solution
Solution:
  1. Step 1: Understand GraphQL schema validation

    GraphQL queries must request fields defined in the schema. If a field is missing, an error occurs.
  2. Step 2: Analyze error message

    The error says 'age' field not found, meaning it is not defined for 'user' in the schema.
  3. Final Answer:

    The 'age' field is not defined in the GraphQL schema for 'user' -> Option A
  4. Quick Check:

    GraphQL fields must exist in schema [OK]
Quick Trick: GraphQL fields must be defined in schema [OK]
Common Mistakes:
  • Assuming any field can be queried
  • Thinking numeric fields are unsupported
  • Believing 'id' is always required

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes