Bird
0
0

Given the fragment:

medium📝 query result Q4 of 15
GraphQL - Queries
Given the fragment:
fragment BookDetails on Book { title author }

and the query:
query { book(id: 5) { ...BookDetails publishedYear } }

Which fields will the query return?
Atitle, author
Btitle, author, publishedYear
CpublishedYear only
Dtitle, publishedYear
Step-by-Step Solution
Solution:
  1. Step 1: Understand fragment fields

    The fragment BookDetails includes title and author.
  2. Step 2: Analyze query fields

    The query selects ...BookDetails plus publishedYear.
  3. Final Answer:

    title, author, publishedYear -> Option B
  4. Quick Check:

    Fragment fields plus explicitly selected fields are returned [OK]
Quick Trick: Query returns fragment fields plus any additional fields listed [OK]
Common Mistakes:
  • Assuming fragment fields override other fields
  • Ignoring additional fields outside fragment
  • Thinking only fragment fields are returned

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes