0
0
GraphQLquery~10 mins

Schema definition 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.

GraphQL
type User { id: [1] }
Drag options to blanks, or click blank then click option'
AString
BID!
CInt
DBoolean
Attempts:
3 left
💡 Hint
Common Mistakes
Using String instead of ID for unique identifiers.
Forgetting the exclamation mark for required fields.
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
BInt
CBoolean
DFloat
Attempts:
3 left
💡 Hint
Common Mistakes
Using Int or Boolean for text fields.
Forgetting to specify the type.
3fill in blank
hard

Fix the error in the schema by completing the type definition correctly.

GraphQL
type User { id: ID, name: [1] }
Drag options to blanks, or click blank then click option'
AString!
BInt!
CBoolean!
DFloat!
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the exclamation mark for required fields.
Using wrong types like Int or Boolean for names.
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 a name and returning a User.

GraphQL
type Mutation { createUser(name: [1]): [2] } type User { id: [3] }
Drag options to blanks, or click blank then click option'
AString!
BUser
CID!
DBoolean
Attempts:
3 left
💡 Hint
Common Mistakes
Using optional types instead of required with !.
Mixing up return types and argument types.