Challenge - 5 Problems
GraphQL Mutation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
What is the result of this mutation?
Given this GraphQL mutation to add a new user:
Assuming the server assigns id 101 to the new user, what is the expected output?
mutation {
addUser(name: "Alice", age: 30) {
id
name
age
}
}Assuming the server assigns id 101 to the new user, what is the expected output?
GraphQL
mutation {
addUser(name: "Alice", age: 30) {
id
name
age
}
}Attempts:
2 left
💡 Hint
Remember the server returns all requested fields with their correct types.
✗ Incorrect
The mutation returns the new user object with all requested fields including the server-assigned id as an integer.
📝 Syntax
intermediate2:00remaining
Identify the syntax error in this mutation
Which option contains a syntax error in this GraphQL mutation?
mutation {
updateUser(id: 5, name: "Bob") {
id
name
}
}GraphQL
mutation {
updateUser(id: 5, name: "Bob") {
id
name
}
}Attempts:
2 left
💡 Hint
Check commas between arguments and braces.
✗ Incorrect
Option B is missing a comma between arguments 'id: 5' and 'name: "Bob"', causing a syntax error.
❓ optimization
advanced2:00remaining
Optimize this mutation to reduce response size
You want to update a user's email but only need the updated email in the response. Which mutation is optimized for minimal response size?
Attempts:
2 left
💡 Hint
Request only the fields you need to reduce data transfer.
✗ Incorrect
Option D requests only the updated email field, minimizing the response size.
🔧 Debug
advanced2:00remaining
Why does this mutation cause an error?
Consider this mutation:
It causes an error. What is the most likely reason?
mutation {
deleteUser(id: "abc") {
id
}
}It causes an error. What is the most likely reason?
GraphQL
mutation {
deleteUser(id: "abc") {
id
}
}Attempts:
2 left
💡 Hint
Check the expected type of the id argument.
✗ Incorrect
The id argument expects an integer, but a string was provided, causing a type error.
🧠 Conceptual
expert3:00remaining
What happens if a mutation requests a non-existent field?
Given this mutation:
Assuming 'nickname' is not a valid field on User, what will the server respond?
mutation {
addUser(name: "Eve", age: 25) {
id
nickname
}
}Assuming 'nickname' is not a valid field on User, what will the server respond?
GraphQL
mutation {
addUser(name: "Eve", age: 25) {
id
nickname
}
}Attempts:
2 left
💡 Hint
GraphQL validates requested fields against the schema before execution.
✗ Incorrect
Requesting a non-existent field causes a validation error and the server returns an error message.