Bird
0
0

Which of the following is the correct GraphQL query syntax to request only the name and age fields of a user?

easy📝 Syntax Q12 of 15
GraphQL - Queries
Which of the following is the correct GraphQL query syntax to request only the name and age fields of a user?
A{ user name age }
B{ user: name, age }
Cquery user { name, age }
D{ user { name age } }
Step-by-Step Solution
Solution:
  1. Step 1: Recall GraphQL query structure

    A query requests a field (like user) and inside braces lists requested subfields.
  2. Step 2: Check each option's syntax

    { user { name age } } correctly nests name and age inside user. Others have syntax errors or wrong structure.
  3. Final Answer:

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

    Correct nesting = { user { name age } } [OK]
Quick Trick: Fields must be inside braces after the parent field [OK]
Common Mistakes:
  • Omitting braces around fields
  • Using commas inside GraphQL queries
  • Incorrect alias or colon usage

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes