0
0
GraphQLquery~10 mins

Code generation from schema 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'
AInt
BString
CID!
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 { id: ID! 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 instead of String for text.
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 posts as a list of Post types.

GraphQL
type User { posts: [[1]!]! }
Drag options to blanks, or click blank then click option'
ABoolean
BString
CID
DPost
Attempts:
3 left
💡 Hint
Common Mistakes
Using scalar types like String or ID instead of the Post type.
Forgetting to add exclamation marks for non-nullability.
4fill in blank
hard

Fill both blanks to define a Query type with a user field that takes an ID argument and returns a User.

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

Fill all three blanks to define a Mutation type with a createUser field that takes a name argument and returns a User.

GraphQL
type Mutation { createUser(name: [1]!): [2] } input CreateUserInput { name: [3]! }
Drag options to blanks, or click blank then click option'
AString
BUser
DID
Attempts:
3 left
💡 Hint
Common Mistakes
Using ID instead of String for the name argument.
Returning a scalar type instead of User.
Mismatching input field types.