Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to specify the standard field for error messages in a GraphQL error response.
GraphQL
{ "errors": [ { "[1]": "Field 'name' is missing" } ] } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'error' or 'msg' instead of 'message' causes the error format to be invalid.
✗ Incorrect
The standard field for error messages in GraphQL error responses is 'message'.
2fill in blank
mediumComplete the code to include the location of the error in the GraphQL error response.
GraphQL
{ "errors": [ { "message": "Invalid query", "[1]": [ { "line": 2, "column": 3 } ] } ] } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'position' or 'coords' instead of 'locations' breaks the standard format.
✗ Incorrect
The 'locations' field specifies where in the query the error occurred.
3fill in blank
hardFix the error in the GraphQL error response by completing the missing field for the error path.
GraphQL
{ "errors": [ { "message": "Cannot query field 'age'", "locations": [ { "line": 3, "column": 5 } ], "[1]": [ "user", "age" ] } ] } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'location' or 'trace' instead of 'path' causes the error format to be incorrect.
✗ Incorrect
The 'path' field shows the path in the query where the error happened.
4fill in blank
hardFill both blanks to add an extensions object with a code and a timestamp to the GraphQL error.
GraphQL
{ "errors": [ { "message": "Unauthorized", "extensions": { "[1]": "UNAUTHENTICATED", "[2]": "2024-06-01T12:00:00Z" } } ] } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'error' or 'time' instead of 'code' or 'timestamp' breaks the standard.
✗ Incorrect
The 'extensions' object uses 'code' for error code and 'timestamp' for the time of error.
5fill in blank
hardFill all three blanks to create a full GraphQL error with message, locations, and path fields.
GraphQL
{ "errors": [ { "[1]": "Field 'email' not found", "[2]": [ { "line": 4, "column": 7 } ], "[3]": [ "user", "email" ] } ] } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'error' instead of 'message' or mixing up 'locations' and 'path' fields.
✗ Incorrect
A complete GraphQL error includes 'message', 'locations', and 'path' fields.