Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a simple GraphQL query to fetch user names.
GraphQL
query { users { [1] } } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing 'email' instead of 'name' when the task asks for user names.
Selecting 'password' which is sensitive and usually not fetched.
✗ Incorrect
The name field fetches user names in GraphQL queries.
2fill in blank
mediumComplete the code to fetch a user's posts with their titles.
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' which fetches the body, not the title.
Selecting 'author' which is not a post title.
✗ Incorrect
The title field fetches the post titles in GraphQL.
3fill in blank
hardFix the error in the GraphQL mutation to create a new user with a name.
GraphQL
mutation { createUser(input: { [1]: "Alice" }) { id name } } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'username' which may not be defined in the schema.
Using 'email' or 'password' which are different fields.
✗ Incorrect
The input field should be name to match the schema for creating a user.
4fill in blank
hardFill both blanks to query users with their names and posts' titles.
GraphQL
query { users { [1] posts { [2] } } } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'email' instead of 'name' for users.
Choosing 'date' instead of 'title' for posts.
✗ Incorrect
The first blank should be name to get user names, and the second blank title to get post titles.
5fill in blank
hardFill all three blanks to write a mutation that updates a post's title and content by id.
GraphQL
mutation { updatePost(id: "[1]", input: { [2]: "New Title", [3]: "Updated content" }) { id title content } } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'postId' instead of just the id value.
Swapping 'title' and 'content' fields.
✗ Incorrect
The post id is 1, and the input fields to update are title and content.