0
0
GraphQLquery~20 mins

Why mutations modify data in GraphQL - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
GraphQL Mutation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Purpose of Mutations in GraphQL
Why do mutations exist in GraphQL?
ATo modify or create data on the server
BTo only fetch data without changes
CTo define the schema structure
DTo handle client-side caching
Attempts:
2 left
💡 Hint
Think about what changes data on the server.
query_result
intermediate
2:00remaining
Mutation Result Output
Given this mutation:
mutation { addBook(title: "New Book", author: "Jane") { id title author } }

What is the expected output if the mutation succeeds?
A{"error":"Cannot fetch data"}
B{"data":{"addBook":null}}
C{"data":{"addBook":{"id":"123","title":"New Book","author":"Jane"}}}
D{"data":{"books":[{"title":"New Book"}]}}
Attempts:
2 left
💡 Hint
Mutations return the changed data as specified in the selection set.
📝 Syntax
advanced
2:00remaining
Identify the Syntax Error in Mutation
Which option contains a syntax error in this mutation?
mutation { updateUser(id: "1", name: "Alice") { id name } }
Amutation { updateUser(id: "1", name: "Alice") { id, name } }
Bmutation { updateUser(id: 1, name: "Alice") { id name } }
Cmutation { updateUser(id: "1", name: "Alice") { id name } }
Dmutation { updateUser(id: "1" name: "Alice") { id name } }
Attempts:
2 left
💡 Hint
Look for missing punctuation between arguments.
optimization
advanced
2:00remaining
Optimizing Mutation Response Size
You want to reduce the data returned by a mutation to improve performance. Which mutation selection set is best?
Amutation { deletePost(id: "5") { id content } }
Bmutation { deletePost(id: "5") { id } }
Cmutation { deletePost(id: "5") { id title } }
Dmutation { deletePost(id: "5") { id title content author { id name } } }
Attempts:
2 left
💡 Hint
Only request the fields you need.
🔧 Debug
expert
3:00remaining
Why Does This Mutation Not Modify Data?
A mutation is sent:
mutation { updateEmail(id: "10", email: "new@example.com") { id email } }

But the email does not change in the database. What is the most likely reason?
AThe mutation resolver does not update the database correctly
BThe mutation name is invalid and causes a syntax error
CThe query is missing a selection set
DThe client did not send the mutation request
Attempts:
2 left
💡 Hint
Check the server-side code that handles the mutation.