0
0
GraphQLquery~10 mins

Schema-first development 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 mark the field as required.
2fill in blank
medium

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

GraphQL
type User { name: [1] }
Drag options to blanks, or click blank then click option'
AInt
BString!
CBoolean
DID
Attempts:
3 left
💡 Hint
Common Mistakes
Using ID instead of String for name.
Omitting the exclamation mark, making the field optional.
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'
AInt
BString
CPost
DBoolean
Attempts:
3 left
💡 Hint
Common Mistakes
Using scalar types like String instead of the Post type.
Forgetting to use square brackets for lists.
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!
BUser
CString
DBoolean
Attempts:
3 left
💡 Hint
Common Mistakes
Using String instead of ID for the argument type.
Returning a scalar type instead of the User object.
5fill in blank
hard

Fill both 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] }
Drag options to blanks, or click blank then click option'
AString!
BUser
CID!
DBoolean
Attempts:
3 left
💡 Hint
Common Mistakes
Using optional argument types without exclamation marks.
Returning scalar types instead of the User object.