Challenge - 5 Problems
Mutation Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
Mutation with required input argument
Given the following GraphQL mutation schema, what will be the result of this mutation call?
Schema snippet:
mutation {
addUser(name: "Alice") {
id
name
}
}Schema snippet:
type Mutation {
addUser(name: String!): User
}
type User {
id: ID!
name: String!
}Attempts:
2 left
💡 Hint
The mutation requires a non-null string argument 'name'.
✗ Incorrect
The mutation 'addUser' requires a non-null 'name' argument. Providing 'Alice' returns a new User object with id and name.
📝 Syntax
intermediate2:00remaining
Identify the syntax error in mutation input
Which option contains a syntax error in the mutation input arguments?
GraphQL
mutation {
updateUser(id: 5, name: "Bob") {
id
name
}
}Attempts:
2 left
💡 Hint
Check the commas between arguments and string quoting.
✗ Incorrect
Option D is missing a comma between arguments 'id: 5' and 'name: "Bob"', causing a syntax error.
❓ optimization
advanced2:00remaining
Optimizing mutation input for multiple fields
You want to update a user's profile with many fields: name, email, age, and address. Which input argument style is best for scalability and clarity?
Attempts:
2 left
💡 Hint
Consider grouping related fields into one input object.
✗ Incorrect
Using a single input object argument (option A) is clearer and easier to extend than listing many separate arguments.
🔧 Debug
advanced2:00remaining
Why does this mutation fail?
Given this mutation call:
And this schema snippet:
Why does the mutation fail?
mutation {
createPost(title: "Hello") {
id
title
}
}And this schema snippet:
type Mutation {
createPost(input: PostInput!): Post
}
input PostInput {
title: String!
content: String!
}
type Post {
id: ID!
title: String!
content: String!
}Why does the mutation fail?
Attempts:
2 left
💡 Hint
Check how the mutation arguments match the schema.
✗ Incorrect
The mutation must provide a single 'input' argument of type PostInput with both 'title' and 'content'. The call provides 'title' directly and omits 'content'.
🧠 Conceptual
expert2:00remaining
Understanding input argument types in mutations
Which statement about input arguments in GraphQL mutations is TRUE?
Attempts:
2 left
💡 Hint
Think about how to organize multiple fields in mutation inputs.
✗ Incorrect
Input object types are designed to group multiple related fields into one argument. Scalars and lists can also be used, and arguments can be non-null.