0
0
GraphQLquery~10 mins

Input arguments for mutations 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 mutation that takes an input argument named 'name'.

GraphQL
type Mutation { createUser(name: [1]): User }
Drag options to blanks, or click blank then click option'
AFloat
BInt
CString!
DBoolean
Attempts:
3 left
💡 Hint
Common Mistakes
Using Int or Boolean instead of String for a name argument.
Forgetting the exclamation mark to make the argument required.
2fill in blank
medium

Complete the mutation argument to accept an input object called 'UserInput'.

GraphQL
type Mutation { addUser(input: [1]): User }
Drag options to blanks, or click blank then click option'
ABoolean
BUser
CString
DUserInput!
Attempts:
3 left
💡 Hint
Common Mistakes
Using the output type 'User' instead of the input type 'UserInput'.
Omitting the exclamation mark for required input.
3fill in blank
hard

Fix the error in the mutation argument type to correctly accept a list of IDs.

GraphQL
type Mutation { deleteUsers(ids: [1]): Boolean }
Drag options to blanks, or click blank then click option'
A[ID!]
BID!
C[ID]
DID
Attempts:
3 left
💡 Hint
Common Mistakes
Using [ID] allows null items in the list, which may cause errors.
Using ID! means a single non-null ID, not a list.
4fill in blank
hard

Fill both blanks to define a mutation that takes a required input object and returns a non-nullable User.

GraphQL
type Mutation { updateUser(input: [1]): [2] }
Drag options to blanks, or click blank then click option'
AUserInput!
BUser
CUser!
DUserInput
Attempts:
3 left
💡 Hint
Common Mistakes
Using nullable types for required inputs or outputs.
Confusing input types with output types.
5fill in blank
hard

Fill all three blanks to define a mutation with an optional string argument 'email', a required boolean 'active', and returns a User.

GraphQL
type Mutation { setUserStatus(email: [1], active: [2]): [3] }
Drag options to blanks, or click blank then click option'
AString
BBoolean!
CUser
DBoolean
Attempts:
3 left
💡 Hint
Common Mistakes
Making optional arguments required by adding exclamation marks.
Forgetting to add exclamation marks for required arguments.