0
0
GraphQLquery~10 mins

Error classification 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 error type with a message field.

GraphQL
type Error { message: [1] }
Drag options to blanks, or click blank then click option'
AInt
BString!
CBoolean
DFloat
Attempts:
3 left
💡 Hint
Common Mistakes
Using Int or Boolean instead of String for error messages.
Forgetting the exclamation mark to make the field required.
2fill in blank
medium

Complete the code to define a GraphQL query that returns a list of errors.

GraphQL
type Query { errors: [[1]!]! }
Drag options to blanks, or click blank then click option'
ABoolean
BString
CError
DInt
Attempts:
3 left
💡 Hint
Common Mistakes
Using String or Int instead of the Error type.
Not marking the list or its items as non-nullable.
3fill in blank
hard

Fix the error in the mutation definition to accept an error message as input.

GraphQL
type Mutation { addError(message: [1]): Error }
Drag options to blanks, or click blank then click option'
AString
BBoolean
CInt
DFloat
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-string types for the message argument.
Omitting the argument type.
4fill in blank
hard

Fill both blanks to define an input type for error classification with a code and message.

GraphQL
input ErrorInput { code: [1] message: [2] }
Drag options to blanks, or click blank then click option'
AInt!
BString
CString!
DBoolean
Attempts:
3 left
💡 Hint
Common Mistakes
Using nullable types when fields should be required.
Using Boolean for message instead of String.
5fill in blank
hard

Fill all three blanks to define a mutation that accepts ErrorInput and returns an Error.

GraphQL
type Mutation { createError(input: [1]): [2] }
Drag options to blanks, or click blank then click option'
AErrorInput!
BError
CError!
DErrorInput
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting exclamation marks for required input or output.
Mixing input and output types.