Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a GraphQL query that fetches a user's name.
GraphQL
query { user(id: "1") { [1] } } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing fields that are not related to the user's name.
✗ Incorrect
The name field is requested to get the user's name in the query.
2fill in blank
mediumComplete the code to request only the needed fields in a GraphQL query.
GraphQL
query { product(id: "5") { id [1] } } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Requesting all fields at once, which GraphQL does not support with 'all'.
✗ Incorrect
GraphQL lets you request only the fields you need, like price here.
3fill in blank
hardFix the error in the GraphQL query to fetch 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 plural or incorrect field names like 'emails' or 'mail'.
✗ Incorrect
The correct field name to get the user's email is email.
4fill in blank
hardFill both blanks to complete a GraphQL mutation that updates a user's name.
GraphQL
mutation { updateUser(id: "3", input: { name: [1] }) { [2] } } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting the new name or requesting wrong fields in the response.
✗ Incorrect
The mutation sets the user's name to "Alice" and requests the updated name field in the response.
5fill in blank
hardFill all three blanks to complete a GraphQL query fetching a post's title and author's name.
GraphQL
query { post(id: [1]) { [2] author { [3] } } } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong id format or requesting wrong fields like 'content' instead of 'title'.
✗ Incorrect
The query fetches the post with id "10", requests its title, and the name of the author.