Bird
0
0

What is wrong with this fragment usage?

medium📝 Debug Q7 of 15
GraphQL - Queries
What is wrong with this fragment usage?
fragment UserInfo on User { id name } query { user { ...UserInfo } ...UserInfo }
AFragments cannot be spread multiple times in the same selection
BFragment spread must be inside a field selection, not at root
CFragment name is case-sensitive and must match exactly
DFragment spread requires parentheses
Step-by-Step Solution
Solution:
  1. Step 1: Understand fragment spread placement

    Fragment spreads must be inside a field selection, not at the root level of the query.
  2. Step 2: Analyze the query

    The second spread '...UserInfo' is outside any field selection, which is invalid.
  3. Final Answer:

    Fragment spread must be inside a field selection, not at root -> Option B
  4. Quick Check:

    Fragment spreads inside fields only [OK]
Quick Trick: Place fragment spreads only inside field selections [OK]
Common Mistakes:
  • Spreading fragments at root level
  • Using parentheses with spreads
  • Ignoring case sensitivity

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes