Bird
0
0

Identify the mistake in this GraphQL fragment usage:

medium📝 Debug Q6 of 15
GraphQL - Queries
Identify the mistake in this GraphQL fragment usage:
fragment ProfileInfo on Profile { id name } query { profile { ...ProfileInfo } fragment ProfileInfo on Profile { email } }
AThe query is missing a root field
BThe fragment is not spread correctly inside the query
CFragments cannot be used inside queries
DThe fragment <code>ProfileInfo</code> is defined twice
Step-by-Step Solution
Solution:
  1. Step 1: Check fragment definitions

    The fragment ProfileInfo is declared twice with different fields.
  2. Step 2: Understand GraphQL rules

    Fragments must have unique names; redefining causes errors.
  3. Final Answer:

    The fragment ProfileInfo is defined twice -> Option D
  4. Quick Check:

    Fragment names must be unique in a document [OK]
Quick Trick: Avoid duplicate fragment names in the same document [OK]
Common Mistakes:
  • Defining fragments multiple times with same name
  • Misusing fragment spread syntax
  • Assuming fragments can be nested inside queries

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes