Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a simple GraphQL query that fetches a user's name.
GraphQL
query GetUserName { user(id: 1) { [1] } } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a field that does not represent the user's name, like age or email.
✗ Incorrect
The field name fetches the user's name as requested.
2fill in blank
mediumComplete the code to add a variable for user ID in the query.
GraphQL
query GetUserName($id: [1]) { user(id: $id) { name } } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
String or Boolean for the user ID variable type.✗ Incorrect
The user ID is typically an integer, so Int is the correct type.
3fill in blank
hardFix the error in the query by completing the missing type declaration.
GraphQL
query GetUser($id: [1]!) { user(id: $id) { name } } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using nullable types or wrong types like String or Boolean.
✗ Incorrect
The exclamation mark ! means the variable is required. The user ID should be an Int and required.
4fill in blank
hardFill both blanks to create a mutation that updates a user's email.
GraphQL
mutation UpdateEmail($id: [1]!, $email: [2]!) { updateUser(id: $id, email: $email) { id email } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up types or forgetting the required
!.✗ Incorrect
User ID is an Int! and email is a String! because emails are text.
5fill in blank
hardFill all three blanks to write a query that fetches a list of users with their IDs, names, and emails.
GraphQL
query GetUsers { users { [1] [2] [3] } } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Including unrelated fields like age or missing required fields.
✗ Incorrect
The query fetches id, name, and email for each user.