0
0
GraphQLquery~10 mins

GraphQL vs REST comparison - Interactive 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 { user(id: "1") { [1] } }
Drag options to blanks, or click blank then click option'
Apassword
Bname
Cemail
Daddress
Attempts:
3 left
💡 Hint
Common Mistakes
Using fields like email or password instead of name.
2fill in blank
medium

Complete the code to specify the HTTP method used by REST to retrieve data.

GraphQL
fetch('/api/users', { method: '[1]' })
Drag options to blanks, or click blank then click option'
AGET
BDELETE
CPUT
DPOST
Attempts:
3 left
💡 Hint
Common Mistakes
Using POST or PUT instead of GET for data retrieval.
3fill in blank
hard

Fix the error in the GraphQL query to fetch a user's email.

GraphQL
query { user(id: "1") { [1] } }
Drag options to blanks, or click blank then click option'
Aemail
Bmail
CuserEmail
Demails
Attempts:
3 left
💡 Hint
Common Mistakes
Using plural or incorrect field names like emails or mail.
4fill in blank
hard

Fill both blanks to complete the REST API call that updates a user's name.

GraphQL
fetch('/api/users/1', { method: '[1]', body: JSON.stringify({ name: '[2]' }) })
Drag options to blanks, or click blank then click option'
APUT
BJohn
CGET
DDELETE
Attempts:
3 left
💡 Hint
Common Mistakes
Using GET or DELETE instead of PUT for updates.
5fill in blank
hard

Fill all three blanks to complete a GraphQL mutation that updates a user's email.

GraphQL
mutation { updateUser(id: "1", input: { [1]: "[2]" }) { [3] } }
Drag options to blanks, or click blank then click option'
Aemail
Bnew.email@example.com
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong field names or returning the wrong field.