Bird
0
0

Find the mistake in this GraphQL query for one-to-many relationship: { author(id: "5") { name book { title } } }

medium📝 Debug Q7 of 15
GraphQL - Type Relationships
Find the mistake in this GraphQL query for one-to-many relationship: { author(id: "5") { name book { title } } }
AQuery should not include nested fields
BField 'book' should be 'books' as it returns a list
CField 'title' should be 'name'
DMissing argument for author query
Step-by-Step Solution
Solution:
  1. Step 1: Check field name for many side

    Since author has many books, the field should be plural 'books' returning a list.
  2. Step 2: Correct field name usage

    Using 'book' (singular) causes error or wrong output; 'books' is correct.
  3. Final Answer:

    Field 'book' should be 'books' as it returns a list -> Option B
  4. Quick Check:

    Use plural field for list returns [OK]
Quick Trick: Use plural field names for lists in queries [OK]
Common Mistakes:
  • Using singular field name for list fields
  • Omitting required query arguments
  • Misnaming nested fields

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes