Bird
0
0

If a GraphQL schema has type Book { title: String, author: Author } and the data is { title: "Dune", author: { name: "Frank" } }, what will the default resolver return for book.author.name?

medium📝 query result Q5 of 15
GraphQL - Resolvers
If a GraphQL schema has type Book { title: String, author: Author } and the data is { title: "Dune", author: { name: "Frank" } }, what will the default resolver return for book.author.name?
A"Frank"
B"Dune"
Cnull
DError: Cannot resolve nested field
Step-by-Step Solution
Solution:
  1. Step 1: Follow default resolver for nested objects

    The default resolver returns the nested object for author, then looks up name inside it.
  2. Step 2: Check the nested data

    The author object has name: "Frank", so the default resolver returns "Frank".
  3. Final Answer:

    "Frank" -> Option A
  4. Quick Check:

    Default resolver handles nested fields by chaining lookups [OK]
Quick Trick: Default resolvers chain lookups for nested fields automatically [OK]
Common Mistakes:
  • Assuming default resolver cannot handle nested objects
  • Returning wrong field value from parent object
  • Expecting errors for nested field resolution

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes