Bird
0
0

Given the GraphQL types:

medium📝 query result Q13 of 15
GraphQL - Type Relationships
Given the GraphQL types:
type Author { id: ID name: String books: [Book] } type Book { id: ID title: String author: Author }

What will the query { author(id: "1") { name books { title } } }
AOnly the list of books without author info
BAuthor's name and a list of their books' titles
COnly the author's name
DAn error because of circular references
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the query structure

    The query asks for an author by id, then requests the author's name and their books' titles.
  2. Step 2: Understand the relationship fields

    The author type has a books field which is a list of Book types, so nested fields like title can be fetched.
  3. Final Answer:

    Author's name and a list of their books' titles -> Option B
  4. Quick Check:

    Nested fields return connected data [OK]
Quick Trick: Nested fields fetch related data in one query [OK]
Common Mistakes:
  • Thinking circular references cause errors in GraphQL
  • Expecting only one level of data returned
  • Ignoring nested fields in query

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes