Bird
0
0

Identify the error in this GraphQL query:

medium📝 Debug Q14 of 15
GraphQL - Basics and Philosophy
Identify the error in this GraphQL query:
query { user(id: 5) { name, email } }
AThe query keyword is missing.
BThe fields 'name' and 'email' should be inside parentheses.
CThe id value should be a string, so it needs quotes.
DGraphQL does not support querying users by id.
Step-by-Step Solution
Solution:
  1. Step 1: Check argument types in GraphQL

    GraphQL requires string arguments to be quoted. Here, id is likely a string and should be "5".
  2. Step 2: Verify field syntax

    Fields 'name' and 'email' are correctly listed with commas, no parentheses needed.
  3. Final Answer:

    The id value should be a string, so it needs quotes. -> Option C
  4. Quick Check:

    String arguments need quotes in GraphQL [OK]
Quick Trick: Quote string arguments in GraphQL queries [OK]
Common Mistakes:
  • Leaving string arguments unquoted
  • Adding parentheses around fields
  • Assuming query keyword is optional

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes