Bird
0
0

A developer sends this GraphQL query:

medium📝 Debug Q6 of 15
GraphQL - Basics and Philosophy
A developer sends this GraphQL query:
query { product(id: 10) { name price } }

The server returns an error. What is the most probable cause?
AThe fields 'name' and 'price' are invalid in GraphQL.
BGraphQL queries cannot have arguments.
CThe id argument should be a string, so it must be quoted.
DThe query must use mutation instead of query.
Step-by-Step Solution
Solution:
  1. Step 1: Check argument syntax

    GraphQL requires string arguments to be quoted.
  2. Step 2: Analyze error cause

    Passing id: 10 without quotes causes syntax error if id is a String type.
  3. Final Answer:

    The id argument should be a string, so it must be quoted. -> Option C
  4. Quick Check:

    String arguments need quotes in GraphQL [OK]
Quick Trick: String arguments must be quoted in GraphQL queries [OK]
Common Mistakes:
  • Passing string arguments without quotes
  • Confusing query and mutation usage
  • Assuming fields are invalid without checking schema

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes