Bird
0
0

Given the mutation below, what will be returned?

medium📝 query result Q13 of 15
GraphQL - Mutations
Given the mutation below, what will be returned?
mutation {
  createPost(title: "Hello") {
    id
    title
  }
}
ANo return data because no fields requested
B{ "data": { "createPost": null } }
C{ "data": { "createPost": { "id": 1, "title": "Hello" } } }
DSyntax error: missing fields
Step-by-Step Solution
Solution:
  1. Step 1: Analyze mutation call and requested fields

    The mutation calls createPost with title "Hello" and requests id and title fields back.
  2. Step 2: Understand expected return

    The server returns the new post's id and title as requested.
  3. Final Answer:

    { "data": { "createPost": { "id": 1, "title": "Hello" } } } -> Option C
  4. Quick Check:

    Requested fields returned in data [OK]
Quick Trick: Requested fields inside mutation braces are returned [OK]
Common Mistakes:
  • Expecting no return data
  • Confusing syntax error with correct syntax
  • Ignoring requested fields in response

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes