Bird
0
0

Find the syntax error in this GraphQL query:

medium📝 Debug Q6 of 15
GraphQL - Basics and Philosophy
Find the syntax error in this GraphQL query:
query { profile { id name } age }
AMissing commas between fields inside 'profile'
BThe 'age' field is outside the 'profile' braces
CThe query keyword is missing
DField names must be capitalized
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the braces

    The 'profile' field opens a brace and includes 'id' and 'name'.
  2. Step 2: Check 'age' placement

    'age' is outside the 'profile' braces, which is invalid if 'age' belongs to 'profile'.
  3. Final Answer:

    The 'age' field is outside the 'profile' braces -> Option B
  4. Quick Check:

    All fields must be inside their parent braces [OK]
Quick Trick: Nested fields must be enclosed within braces [OK]
Common Mistakes:
  • Placing fields outside their parent braces
  • Using commas between fields (GraphQL does not require commas)
  • Omitting the 'query' keyword (optional but valid)

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes