Bird
0
0

You want to fetch a list of authors with their books and each book's reviews including rating and comment. Which query correctly nests these fields?

hard📝 Application Q15 of 15
GraphQL - Queries
You want to fetch a list of authors with their books and each book's reviews including rating and comment. Which query correctly nests these fields?
A{ authors { name books { title reviews { rating comment } } } }
B{ authors { name books { title } reviews { rating comment } } }
C{ authors { name { books { title reviews { rating comment } } } } }
D{ authors { name books reviews { rating comment } } }
Step-by-Step Solution
Solution:
  1. Step 1: Understand nesting requirements

    Reviews belong to each book, so reviews must be nested inside books.
  2. Step 2: Check each option's nesting

    { authors { name books { title reviews { rating comment } } } } correctly nests reviews inside books. { authors { name books { title } reviews { rating comment } } } places reviews outside books. { authors { name { books { title reviews { rating comment } } } } } nests books inside name incorrectly. { authors { name books reviews { rating comment } } } misses nesting reviews inside books.
  3. Final Answer:

    { authors { name books { title reviews { rating comment } } } } -> Option A
  4. Quick Check:

    Nested fields must follow data hierarchy [OK]
Quick Trick: Nest fields inside their parent objects to match data structure [OK]
Common Mistakes:
  • Placing nested fields at wrong levels
  • Nesting fields inside scalar fields
  • Missing braces for nested objects

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes