0
0
GraphQLquery~10 mins

Schema linting 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 with a non-nullable String field called 'name'.

GraphQL
type User { name: [1] }
Drag options to blanks, or click blank then click option'
AFloat
BInt
CBoolean
DString!
Attempts:
3 left
💡 Hint
Common Mistakes
Using just 'String' without the exclamation mark.
Using a wrong type like 'Int' or 'Boolean' for a name field.
2fill in blank
medium

Complete the code to add a description to the 'User' type using GraphQL schema comments.

GraphQL
"""[1]"""
type User { id: ID! }
Drag options to blanks, or click blank then click option'
AList of users
BUser ID field
CUser represents a system user
DQuery for users
Attempts:
3 left
💡 Hint
Common Mistakes
Putting a field name instead of a description.
Using single quotes instead of triple quotes.
3fill in blank
hard

Fix the error in the schema by completing the code to define a list of non-nullable 'Post' types inside 'User'.

GraphQL
type User { posts: [[1]]! }
Drag options to blanks, or click blank then click option'
APost
BPost!
CPost[]
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Post' without exclamation mark inside the list.
Using invalid syntax like 'Post[]'.
4fill in blank
hard

Fill both blanks to define a mutation 'createUser' that takes a non-nullable 'name' argument of type String and returns a 'User'.

GraphQL
type Mutation { createUser(name: [1]): [2] }
Drag options to blanks, or click blank then click option'
AString!
BUser
CBoolean
DInt
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting the exclamation mark on the argument type.
Returning a wrong type like Boolean or Int.
5fill in blank
hard

Fill all three blanks to define a query 'getUser' that takes a non-nullable 'id' argument of type ID and returns a nullable 'User'.

GraphQL
type Query { getUser(id: [1]): [2] }
Drag options to blanks, or click blank then click option'
AID!
BUser
CUser!
DString
Attempts:
3 left
💡 Hint
Common Mistakes
Making the return type non-nullable with an exclamation mark.
Using wrong argument type like String instead of ID.