Bird
0
0

Which of the following is the correct GraphQL query to select the fields name and age from a user object?

easy📝 Syntax Q3 of 15
GraphQL - Queries
Which of the following is the correct GraphQL query to select the fields name and age from a user object?
A{ user { name, age } }
B{ user (name, age) }
C{ user [name age] }
D{ user { name age } }
Step-by-Step Solution
Solution:
  1. Step 1: Understand GraphQL field selection syntax

    Fields inside braces are listed with spaces, not commas or parentheses.
  2. Step 2: Check each option

    { user { name, age } } uses commas (invalid), { user (name, age) } uses parentheses (invalid), { user [name age] } uses square brackets (invalid). { user { name age } } uses correct syntax with space-separated fields inside braces.
  3. Final Answer:

    { user { name age } } -> Option D
  4. Quick Check:

    Correct field list syntax = Space-separated inside braces [OK]
Quick Trick: List fields with spaces inside braces, no commas [OK]
Common Mistakes:
  • Using commas between fields
  • Using parentheses instead of braces
  • Using square brackets for fields

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes