0
0
GraphQLquery~10 mins

Update mutation pattern in GraphQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a GraphQL mutation to update a user's name.

GraphQL
mutation UpdateUserName($id: ID!, $name: String!) {
  updateUser(id: $id, input: { name: [1] }) {
    id
    name
  }
}
Drag options to blanks, or click blank then click option'
A$name
Bid
C$id
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using the field name 'name' instead of the variable '$name'.
Using the user ID variable instead of the name variable.
2fill in blank
medium

Complete the code to specify the mutation name correctly.

GraphQL
mutation [1]($id: ID!, $email: String!) {
  updateUser(id: $id, input: { email: $email }) {
    id
    email
  }
}
Drag options to blanks, or click blank then click option'
Aupdate_email
BUpdateUserEmail
CupdateUserEmail
DUpdate_Email
Attempts:
3 left
💡 Hint
Common Mistakes
Using snake_case or PascalCase for mutation names.
Starting mutation names with uppercase letters.
3fill in blank
hard

Fix the error in the mutation argument to correctly pass the user ID.

GraphQL
mutation updateUser($id: ID!, $name: String!) {
  updateUser(id: [1], input: { name: $name }) {
    id
    name
  }
}
Drag options to blanks, or click blank then click option'
A$id
Bname
C$name
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the field name 'id' instead of the variable '$id'.
Passing the name variable instead of the ID variable.
4fill in blank
hard

Fill both blanks to complete the mutation that updates a user's age and returns the updated age and name.

GraphQL
mutation [1]($id: ID!, $age: Int!) {
  updateUser(id: $id, input: { age: [2] }) {
    age
    name
  }
}
Drag options to blanks, or click blank then click option'
AupdateUserAge
B$age
C$name
Dage
Attempts:
3 left
💡 Hint
Common Mistakes
Using the field name 'age' instead of the variable '$age' in the input.
Using the wrong mutation name format.
5fill in blank
hard

Fill all three blanks to write a mutation that updates a user's profile with name and email, and returns the id, name, and email.

GraphQL
mutation [1]($id: ID!, $name: String!, $email: String!) {
  updateUser(id: $id, input: { name: [2], email: [3] }) {
    id
    name
    email
  }
}
Drag options to blanks, or click blank then click option'
AupdateUserProfile
B$name
C$email
DuserProfileUpdate
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong mutation name.
Passing input fields without the dollar sign variables.