0
0
GraphQLquery~10 mins

Enum types 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 an enum type for colors.

GraphQL
enum Color {
  RED
  GREEN
  [1]
}
Drag options to blanks, or click blank then click option'
AORANGE
BYELLOW
CBLUE
DPURPLE
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase enum values.
Adding values not related to colors.
2fill in blank
medium

Complete the code to use the enum type Status in a GraphQL schema.

GraphQL
type Task {
  id: ID!
  title: String!
  status: [1]
}
Drag options to blanks, or click blank then click option'
AString
BInt
CBoolean
DStatus
Attempts:
3 left
💡 Hint
Common Mistakes
Using a scalar type like String instead of the enum type.
Forgetting to capitalize the enum type name.
3fill in blank
hard

Fix the error in the enum definition by completing the missing value.

GraphQL
enum Direction {
  NORTH
  EAST
  SOUTH
  [1]
}
Drag options to blanks, or click blank then click option'
AWEST
BUP
CDOWN
DLEFT
Attempts:
3 left
💡 Hint
Common Mistakes
Using directions like UP or DOWN which are not part of compass points.
Using lowercase or misspelled values.
4fill in blank
hard

Fill both blanks to define an enum and use it in a type.

GraphQL
enum Priority {
  [1]
  LOW
  MEDIUM
}

type Issue {
  id: ID!
  priority: [2]
}
Drag options to blanks, or click blank then click option'
AHIGH
BPriority
CString
DURGENT
Attempts:
3 left
💡 Hint
Common Mistakes
Using a scalar type like String instead of the enum type for the field.
Adding invalid enum values.
5fill in blank
hard

Fill all three blanks to define an enum, use it in a type, and set a default value.

GraphQL
enum Role {
  [1]
  USER
  ADMIN
}

input User {
  id: ID!
  role: [2] = [3]
}
Drag options to blanks, or click blank then click option'
AGUEST
BRole
DString
Attempts:
3 left
💡 Hint
Common Mistakes
Using a scalar type like String instead of the enum type for the field.
Not setting a default value or using an invalid default.
Using lowercase enum values.