0
0
GraphQLquery~10 mins

Why schema design affects usability in GraphQL - Test Your Understanding

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'
AInt
BString
CID
DBoolean
Attempts:
3 left
💡 Hint
Common Mistakes
Using String instead of ID for unique identifiers.
Using Int which may not be unique or descriptive enough.
2fill in blank
medium

Complete the code to make the 'name' field required in the User type.

GraphQL
type User { name: [1] }
Drag options to blanks, or click blank then click option'
AString!
BString
CID
DBoolean
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the exclamation mark, making the field optional.
Using incorrect types like Boolean for a name.
3fill in blank
hard

Fix the error in the query by completing the field name correctly.

GraphQL
{ user(id: "1") { [1] } }
Drag options to blanks, or click blank then click option'
Aname
Busername
Cid
Demail
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'username' which is not defined in the schema.
Using 'email' when the schema does not include it.
4fill in blank
hard

Fill both blanks to define a query that fetches a list of users with their IDs and names.

GraphQL
type Query { users: [1] { id: [2] } }
Drag options to blanks, or click blank then click option'
A[User]
BID
CString
DUser
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'User' instead of '[User]' for a list.
Using 'String' instead of 'ID' for the id field.
5fill in blank
hard

Fill all three blanks to define a mutation that creates a user with a required name and returns the user's ID.

GraphQL
type Mutation { createUser(name: [1]): [2] { id: [3] } }
Drag options to blanks, or click blank then click option'
AString!
BUser
CID
DBoolean
Attempts:
3 left
💡 Hint
Common Mistakes
Making the name optional by omitting the exclamation mark.
Returning a Boolean instead of a User.
Using String instead of ID for the id field.