Added Apollo Server GraphQL API error message for failed requests#129
Added Apollo Server GraphQL API error message for failed requests#129andreachild merged 3 commits intoaws:mainfrom
Conversation
beb9204 to
91270ef
Compare
| }; | ||
| } | ||
|
|
||
| throw new Error(`Neptune query failed: ${err.message || err}`); |
There was a problem hiding this comment.
This module is also used by the lambda code, so need to check if the lambda code needs to adapt to handle this thrown error.
Since this also affects the lambda, we can add an integration test that if we try to send a graphQL query request with a bad auth token, we should receive an appropriate error response with a useful message.
For example the Case05.02.test.js currently has a test 'Can query app sync API successfully', we can add an additional test for 'Should receive 403 response with appropriate error message' where we make a query with an invalid auth token and check the response has 403 status and a suitable error message.
There was a problem hiding this comment.
If I run the executeAppSyncQuery with an invalid token, it returns a 401 error response from AppSync and not Neptune as I think the invalid token is stopped by AppSync before the call to Lambda is made. Instead should I try to make a unit test in the resolver unit tests using a mock to trigger the queryNeptune function directly ?
There was a problem hiding this comment.
That makes sense, for app sync integration tests it would be sufficient to validate that 401 is returned with an appropriate error message.
There was a problem hiding this comment.
I'll add this test as part of a separate PR
Co-authored-by: andreachild <andrea.child@improving.com>
5e9d447 to
fb4f3c3
Compare
Any expired security tokens or network connectivity errors when using the GraphQL API with the apollo server resulted in a cryptic error message that was not helpful for debugging.
Added an error catch message in the Apollo Server to ensure that when these errors result it returns a more useful error message that will help with the debugging of the error.