0
0
GraphQLquery~20 mins

GraphQL error format - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
GraphQL Error Format Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
What is the output error message format for a GraphQL query with a syntax error?
Consider a GraphQL query with a missing closing brace. What does the error response look like?
GraphQL
query { user(id: 1) { name }
A{"errors":[{"message":"Syntax Error: Expected Name, found <EOF>","locations":[{"line":1,"column":26}]}]}
B{"error":"Syntax error at line 1"}
C{"message":"Unexpected end of query"}
D{"errors":[{"msg":"Missing closing brace"}]}
Attempts:
2 left
💡 Hint
GraphQL errors include an 'errors' array with detailed message and location.
query_result
intermediate
2:00remaining
What does a GraphQL error response contain when a requested field does not exist?
If a query asks for a field 'age' on a type that does not have it, what error response is returned?
GraphQL
query { user(id: 1) { age } }
A{"message":"Invalid field age"}
B{"error":"Field age not found"}
C{"errors":[{"message":"Cannot query field \"age\" on type \"User\".","locations":[{"line":1,"column":15}]}]}
D{"errors":[{"msg":"Field age missing in schema"}]}
Attempts:
2 left
💡 Hint
GraphQL error messages specify the field and type causing the issue.
📝 Syntax
advanced
2:30remaining
Which option correctly shows the GraphQL error format for a validation error with multiple errors?
A query has two errors: a missing field and a wrong argument type. What is the correct error response format?
GraphQL
query { user(id: "abc") { name age } }
A{"errors":[{"message":"Argument \"id\" has invalid value \"abc\".","locations":[{"line":1,"column":13}]},{"message":"Cannot query field \"age\" on type \"User\".","locations":[{"line":1,"column":25}]}]}
B{"errors":[{"msg":"Invalid id argument"},{"msg":"Field age missing"}]}
C{"error":"Multiple errors found"}
D{"errors":[{"message":"id argument error"},{"message":"age field error"}]}
Attempts:
2 left
💡 Hint
GraphQL errors list each error with message and location in an array.
🧠 Conceptual
advanced
1:30remaining
What key fields are always present in a GraphQL error object?
Select the fields that are always included in each error object returned by a GraphQL server.
A"error" and "code"
B"message" and "locations"
C"msg" and "line"
D"description" and "position"
Attempts:
2 left
💡 Hint
Look for the standard keys used in GraphQL error objects.
🔧 Debug
expert
3:00remaining
Why does this GraphQL error response cause a client parsing failure?
Given this error response: {"errors":[{"message":"Field 'name' not found"}]} but the client expects 'locations' field as well, what is the issue?
AThe JSON is invalid because of missing commas.
BThe 'message' field is incorrectly formatted as a string instead of an object.
CThe 'errors' key should be a string, not an array.
DThe error object is missing the required 'locations' field, causing client parsing failure.
Attempts:
2 left
💡 Hint
GraphQL clients expect a consistent error object structure.