Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle errors thrown in subgraph #61

Merged

Conversation

chrstnmcf
Copy link
Contributor

When an exception was thrown in a graphql endpoint (not an exception in GraphQl but before, e.g. the context) the graphql composer was not able to handle this properly. It was just checking if errors was set in the response and if it was not present tried to access the subgraph response from data which was not returned in the case of an exception thrown before. This resulted in a Cannot read properties of undefined error. To avoid this we now check if error is present in the response and throw an error in that case.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

Thanks for opening a PR! Can you please add a unit test?

@chrstnmcf
Copy link
Contributor Author

@mcollina My bad, thanks for the hint! Added the missing unit tests.

@chrstnmcf chrstnmcf requested a review from mcollina September 16, 2024 13:03
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm, thanks!

@mcollina mcollina merged commit 6c3c807 into platformatic:main Sep 19, 2024
4 checks passed
mcollina pushed a commit that referenced this pull request Sep 19, 2024
* fix: handle errors thrown in subgraph

* test: added tests for makeGraphqlRequest

* test: remove validationRules from test
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