Bird
0
0

A developer writes this GraphQL query to the single endpoint:

medium📝 Debug Q6 of 15
GraphQL - Basics and Philosophy
A developer writes this GraphQL query to the single endpoint:
{ user(id: 1) { name email } }
but receives an error. What is the likely cause?
AThe query must use mutation keyword
BThe id value should be a string, not a number
CGraphQL does not support querying user data
DThe endpoint URL is incorrect
Step-by-Step Solution
Solution:
  1. Step 1: Check query syntax and types

    The id argument is given as a number (1) but usually GraphQL expects string ids in quotes.
  2. Step 2: Identify common GraphQL error

    Passing wrong type causes validation error at the single endpoint.
  3. Final Answer:

    The id value should be a string, not a number -> Option B
  4. Quick Check:

    Argument types must match schema = id as string [OK]
Quick Trick: Always match argument types exactly in queries [OK]
Common Mistakes:
  • Using number instead of string for id
  • Assuming endpoint URL is wrong without checking
  • Confusing query with mutation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes