0
0
GraphQLquery~10 mins

Why error handling differs from REST in GraphQL - Test Your Understanding

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

Complete the code to query a GraphQL API for a user's name.

GraphQL
query { user(id: [1]) { name } }
Drag options to blanks, or click blank then click option'
AuserId
B"123"
C123
D'123'
Attempts:
3 left
💡 Hint
Common Mistakes
Using unquoted numbers for string IDs
Using single quotes instead of double quotes
2fill in blank
medium

Complete the code to handle errors in a GraphQL response.

GraphQL
if (response.[1]) { console.error(response.errors); }
Drag options to blanks, or click blank then click option'
Aerrors
Bdata
Cstatus
Dmessage
Attempts:
3 left
💡 Hint
Common Mistakes
Checking 'data' instead of 'errors'
Checking HTTP status codes only
3fill in blank
hard

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

GraphQL
query { user(id: [1]) { email } }
Drag options to blanks, or click blank then click option'
A'123'
B123
C"123"
DuserId
Attempts:
3 left
💡 Hint
Common Mistakes
Using unquoted numbers
Using single quotes instead of double quotes
4fill in blank
hard

Fill both blanks to check if a GraphQL response has errors and log them.

GraphQL
if (response.[1] && response.[2].length > 0) { console.log('Errors found'); }
Drag options to blanks, or click blank then click option'
Aerrors
Bdata
Cstatus
Dmessage
Attempts:
3 left
💡 Hint
Common Mistakes
Checking 'data' or 'status' instead of 'errors'
5fill in blank
hard

Fill all three blanks to extract data, check errors, and handle them in GraphQL response.

GraphQL
const [1] = response.[2];
if (response.[3]) { console.error('GraphQL errors:', response.errors); }
Drag options to blanks, or click blank then click option'
Adata
Cerrors
Dstatus
Attempts:
3 left
💡 Hint
Common Mistakes
Checking 'status' instead of 'errors'
Not extracting 'data' properly