Bird
0
0

Which of the following is the correct GraphQL syntax to select the fields id and name from a user?

easy📝 Syntax Q12 of 15
GraphQL - Queries
Which of the following is the correct GraphQL syntax to select the fields id and name from a user?
A{ user: id, name }
B{ user(id, name) }
Cquery user { id, name }
D{ user { id, name } }
Step-by-Step Solution
Solution:
  1. Step 1: Recall GraphQL field selection syntax

    Fields are selected inside curly braces after the type name, separated by commas or spaces.
  2. Step 2: Check each option's syntax

    { user { id, name } } correctly uses braces and field names inside user. Others have syntax errors or wrong structure.
  3. Final Answer:

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

    Correct field selection syntax = { user { id, name } } [OK]
Quick Trick: Use braces to nest fields inside the type name [OK]
Common Mistakes:
  • Using colon instead of braces for fields
  • Omitting braces around fields
  • Trying to pass fields as function arguments

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes