Skip to content

Comments

Added Apollo Server GraphQL API error message for failed requests#129

Merged
andreachild merged 3 commits intoaws:mainfrom
flora-jin:errorMessage
Sep 4, 2025
Merged

Added Apollo Server GraphQL API error message for failed requests#129
andreachild merged 3 commits intoaws:mainfrom
flora-jin:errorMessage

Conversation

@flora-jin
Copy link
Contributor

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.

};
}

throw new Error(`Neptune query failed: ${err.message || err}`);
Copy link
Contributor

@andreachild andreachild Aug 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

@flora-jin flora-jin Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, for app sync integration tests it would be sufficient to validate that 401 is returned with an appropriate error message.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add this test as part of a separate PR

@andreachild andreachild merged commit 526bc1a into aws:main Sep 4, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants