Bird
0
0

Which of the following is a valid way to define a fragment named PostDetails on type Post?

easy📝 Conceptual Q2 of 15
GraphQL - Queries
Which of the following is a valid way to define a fragment named PostDetails on type Post?
Afragment PostDetails on Post { id title content }
Bfragment PostDetails { id title content }
Cfragment PostDetails on { id title content }
Dfragment PostDetails Post { id title content }
Step-by-Step Solution
Solution:
  1. Step 1: Recall fragment syntax

    Fragments must be defined with the keyword 'fragment', a name, the keyword 'on', and the type name, followed by the selection set.
  2. Step 2: Check each option

    fragment PostDetails on Post { id title content } follows the correct syntax: 'fragment PostDetails on Post { ... }'. Others miss 'on' or type name or have wrong order.
  3. Final Answer:

    fragment PostDetails on Post { id title content } -> Option A
  4. Quick Check:

    Fragment syntax = 'fragment Name on Type { fields }' [OK]
Quick Trick: Fragments need 'on' keyword and type name after fragment name [OK]
Common Mistakes:
  • Omitting 'on' keyword
  • Leaving out type name
  • Wrong order of keywords

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes