0
0
GraphQLquery~10 mins

Migration from REST to GraphQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
Aemail
Bname
Cid
Dpassword
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.
2fill in blank
medium

Complete 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'
Atitle
Bauthor
Cdate
Dcontent
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing 'content' which fetches the body, not the title.
Selecting 'author' which is not a post title.
3fill in blank
hard

Fix 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'
Ausername
Bpassword
Cemail
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'username' which may not be defined in the schema.
Using 'email' or 'password' which are different fields.
4fill in blank
hard

Fill 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'
Aname
Btitle
Cdate
Demail
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'email' instead of 'name' for users.
Choosing 'date' instead of 'title' for posts.
5fill in blank
hard

Fill 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'
A1
Btitle
Ccontent
DpostId
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'postId' instead of just the id value.
Swapping 'title' and 'content' fields.