0
0
GraphQLquery~10 mins

Input validation patterns 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 input type with a required string field.

GraphQL
input UserInput {
  name: [1]!
}
Drag options to blanks, or click blank then click option'
ABoolean
BInt
CFloat
DString
Attempts:
3 left
💡 Hint
Common Mistakes
Using Int or Boolean for a text field.
Forgetting the exclamation mark to make the field required.
2fill in blank
medium

Complete the code to add an optional integer field for age in the input type.

GraphQL
input UserInput {
  age: [1]
}
Drag options to blanks, or click blank then click option'
AFloat!
BInt
CBoolean!
DString!
Attempts:
3 left
💡 Hint
Common Mistakes
Adding an exclamation mark making the field required when it should be optional.
Using String instead of Int for numbers.
3fill in blank
hard

Fix the error in the input type by choosing the correct scalar type for a boolean field.

GraphQL
input UserInput {
  isActive: [1]!
}
Drag options to blanks, or click blank then click option'
ABoolean
BInt
CFloat
DString
Attempts:
3 left
💡 Hint
Common Mistakes
Using String or Int for boolean fields.
Forgetting the exclamation mark for required fields.
4fill in blank
hard

Fill both blanks to create an input type with a required email string and an optional age integer.

GraphQL
input UserInput {
  email: [1]!
  age: [2]
}
Drag options to blanks, or click blank then click option'
AString
BInt!
CInt
DBoolean
Attempts:
3 left
💡 Hint
Common Mistakes
Making the age field required by adding !.
Using Boolean for email or age fields.
5fill in blank
hard

Fill all three blanks to define an input type with a required username string, an optional age integer, and a required active boolean.

GraphQL
input UserInput {
  username: [1]!
  age: [2]
  active: [3]!
}
Drag options to blanks, or click blank then click option'
AString
BInt
CBoolean
DFloat
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to add ! for required fields.
Using wrong scalar types for fields.