Bird
0
0

Which of the following is the correct syntax to query a nested field comments inside posts for a user in GraphQL?

easy📝 Syntax Q3 of 15
GraphQL - Queries
Which of the following is the correct syntax to query a nested field comments inside posts for a user in GraphQL?
A{ user { posts.comments } }
B{ user { comments { posts } } }
C{ user { posts: comments } }
D{ user { posts { comments } } }
Step-by-Step Solution
Solution:
  1. Step 1: Understand GraphQL nested syntax

    Nested fields are queried by placing them inside curly braces under their parent field.
  2. Step 2: Check each option's syntax

    { user { posts { comments } } } correctly nests comments inside posts. Others have invalid syntax or wrong nesting.
  3. Final Answer:

    { user { posts { comments } } } -> Option D
  4. Quick Check:

    Correct nested syntax = { user { posts { comments } } } [OK]
Quick Trick: Use curly braces to nest fields inside parent fields [OK]
Common Mistakes:
  • Using dot notation instead of braces
  • Swapping parent and child fields
  • Using colon instead of braces for nesting

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes