0
0
GraphQLquery~10 mins

GraphQL IDE extensions - 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 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'
Aage
Bname
Cemail
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing fields like age or email which do not fetch the name.
Using id instead of name.
2fill in blank
medium

Complete the code to add an argument to fetch a user by their username.

GraphQL
query GetUser { user([1]: "alice") { id name } }
Drag options to blanks, or click blank then click option'
Aid
Bemail
Cusername
Dage
Attempts:
3 left
💡 Hint
Common Mistakes
Using id instead of username.
Using email or age which are not the correct arguments here.
3fill in blank
hard

Fix the error in the GraphQL query to correctly fetch a list of posts with their titles.

GraphQL
query { posts { [1] } }
Drag options to blanks, or click blank then click option'
Atitles
Bname
CpostTitle
Dtitle
Attempts:
3 left
💡 Hint
Common Mistakes
Using plural titles which is not a valid field.
Using postTitle or name which do not exist.
4fill in blank
hard

Fill both blanks to create a mutation that adds a new user with a name and email.

GraphQL
mutation AddUser { addUser(name: [1], email: [2]) { id name email } }
Drag options to blanks, or click blank then click option'
A"Alice"
B"alice@example.com"
C"Bob"
D"bob@example.com"
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around string values.
Mixing up name and email values.
5fill in blank
hard

Fill all three blanks to write a query that fetches a user's id, name, and their posts' titles.

GraphQL
query GetUserPosts { user(id: [1]) { [2] posts { [3] } } }
Drag options to blanks, or click blank then click option'
A1
Bname
Ctitle
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around numeric id.
Using wrong field names for posts.