Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to query the name of a user by their ID.
GraphQL
query { user(id: [1]) { name } } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using an unquoted number for the ID
Using a field name instead of a value
✗ Incorrect
The user ID must be a string, so it needs quotes around it.
2fill in blank
mediumComplete the code to fetch the posts' titles for a user.
GraphQL
query { user(id: "1") { posts { [1] } } } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing content instead of title
Selecting author which is a nested object
✗ Incorrect
We want to get the titles of the posts, so the field is title.
3fill in blank
hardFix the error in the query to get a user's email.
GraphQL
query { user(id: "2") { [1] } } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using emailAddress which is not defined
Using mail or contact which are incorrect
✗ Incorrect
The correct field for the user's email is email.
4fill in blank
hardFill both blanks to query a user's posts with their titles and dates.
GraphQL
query { user(id: "3") { posts { [1] [2] } } } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing content instead of date
Including author which is a nested object
✗ Incorrect
We want the post's title and date fields.
5fill in blank
hardFill all three blanks to query a user's name, email, and their posts' titles.
GraphQL
query { user(id: "4") { [1] [2] posts { [3] } } } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up email and content fields
Forgetting to include the posts field
✗ Incorrect
The user fields are name and email, and for posts, we want title.