0
0
GraphQLquery~10 mins

Schema testing 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 type for a User with an ID field.

GraphQL
type User { id: [1] }
Drag options to blanks, or click blank then click option'
AID!
BString
CInt
DBoolean
Attempts:
3 left
💡 Hint
Common Mistakes
Using String instead of ID for unique identifiers.
Forgetting the exclamation mark to make the field required.
2fill in blank
medium

Complete the code to add a name field of type String to the User type.

GraphQL
type User { name: [1] }
Drag options to blanks, or click blank then click option'
AString!
BID
CBoolean
DInt
Attempts:
3 left
💡 Hint
Common Mistakes
Using ID instead of String for text fields.
Omitting the exclamation mark if the field is required.
3fill in blank
hard

Fix the error in the schema by completing the field type for age.

GraphQL
type User { age: [1] }
Drag options to blanks, or click blank then click option'
AString!
BBoolean
CID
DInt!
Attempts:
3 left
💡 Hint
Common Mistakes
Using String or Boolean for age.
Forgetting the exclamation mark for required fields.
4fill in blank
hard

Fill both blanks to define a Query type with a user field returning a User by ID.

GraphQL
type Query { user(id: [1]): [2] }
Drag options to blanks, or click blank then click option'
AID!
BUser
CString
DBoolean
Attempts:
3 left
💡 Hint
Common Mistakes
Using String instead of ID for the id argument.
Returning String or Boolean instead of User.
5fill in blank
hard

Fill all three blanks to define a Mutation type with createUser taking name and age and returning User.

GraphQL
type Mutation { createUser(name: [1], age: [2]): [3] }
Drag options to blanks, or click blank then click option'
AString!
BInt!
CUser
DBoolean
Attempts:
3 left
💡 Hint
Common Mistakes
Using optional types instead of required with exclamation marks.
Returning Boolean instead of User.