Bird
0
0

How would you modify this query to also fetch each comment's author name?

hard📝 Application Q9 of 15
GraphQL - Queries
How would you modify this query to also fetch each comment's author name?
{ posts { title comments { text } } }
A{ posts { title comments { text author.name } } }
B{ posts { title comments { text author { name } } } }
C{ posts { title comments { text, author.name } } }
D{ posts { title comments { text author } } }
Step-by-Step Solution
Solution:
  1. Step 1: Understand nested fields for author name

    Author is an object inside comments, so we nest author { name } inside comments.
  2. Step 2: Check syntax correctness

    { posts { title comments { text author { name } } } } correctly nests author { name }. Others use invalid dot notation or incomplete nesting.
  3. Final Answer:

    { posts { title comments { text author { name } } } } -> Option B
  4. Quick Check:

    Use braces to nest object fields properly [OK]
Quick Trick: Nest object fields with braces, not dot notation [OK]
Common Mistakes:
  • Using dot notation inside braces
  • Not nesting author name inside author
  • Assuming author is scalar field

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes