-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
feat(api): expose HTTP response from API errors #12835
Conversation
// TODO: Delete the following 2 lines after we change the build target to >= es2015 | ||
this.constructor = APIError; | ||
Object.setPrototypeOf(this, APIError.prototype); | ||
this.constructor = GraphQLApiError; | ||
Object.setPrototypeOf(this, GraphQLApiError.prototype); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think the current build target is es2020 😀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, we have quite a few places with this and I'm going to follow up with a PR. The only thing I need to make sure is we don't use es5 for UMD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the UMD uses the es6 class
keyword. Will remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually not quite. Removing this will break the current Jest test. We have defer it to the Jest upgrade.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a new one for me. Got a link explaining what the issue is in more detail?
c1fdb0f
to
2bf22dd
Compare
Co-authored-by: Hui Zhao <[email protected]>
2bf22dd
to
7b78705
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #12835 +/- ##
==========================================
- Coverage 88.00% 87.28% -0.72%
==========================================
Files 663 635 -28
Lines 18141 13446 -4695
Branches 3635 2462 -1173
==========================================
- Hits 15965 11737 -4228
+ Misses 2176 1709 -467
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very much appreciate the detailed PR description, thank you!
// TODO: Delete the following 2 lines after we change the build target to >= es2015 | ||
this.constructor = APIError; | ||
Object.setPrototypeOf(this, APIError.prototype); | ||
this.constructor = GraphQLApiError; | ||
Object.setPrototypeOf(this, GraphQLApiError.prototype); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a new one for me. Got a link explaining what the issue is in more detail?
Hey, @svidgen Re: #12835 (comment), it was mainly because I need to make sure both |
* chore(auth): debounce refreshAuthTokens (#12845) * chore: add debounce callback helper * chore: add unit tests * chore: debounce fetchAuthSession * chore: fix unit test * chore: fix bundle size limits * chore: update debounce logic * chore: update dedup logic * chore: debounce refreshAuthTokens * chore: fix bundle size * chore: address feedback * chore: fix unit test * chore: address feedback * chore: update yarn.lock * chore: address feedbak * fix(data): update DataStore to send correct Control Messages when starting (#12861) * chore(release): Publish [ci skip] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - [email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - [email protected] * chore(release): update API docs [ci skip] * chore: enable codecov (#12876) * docs(auth,analytics): adding in-line docs for public apis (#12882) * docs(auth,analytics): adding in-line docs for public apis * fix: unblock the max length lint * chore(react-native): use react-native 0.71.0 as the dev dep * fix: Default branch resolution when running E2E tests (#12910) * fix: Lambda auth config value (#12922) * chore: renable caching the package list in GH actions * chore: remove unused codecov package (has been deprecated) * feat(api): expose HTTP response from API errors (#12835) --------- Co-authored-by: Hui Zhao <[email protected]> Co-authored-by: Jim Blanchard <[email protected]> * chore: temporarily disable codecov GH action integration (#12928) * ci: run flaky data e2es without retry (#12758) * ci: run flaky data e2es without retry * only run on chrome * restore workflow --------- Co-authored-by: Aaron S <[email protected]> * fix(core): Amplify.configure dispatches Hub event with unparsed config object (#12930) * chore(repo): use typescript 5.0.2 across workspace * chore(repo): refactor tsconfig hierarchy - move the base tsconfig into the root of the workspace - unifying tsconfig tsconfig.build tsconfig.test and tsconfig.watch settings * chore(repo): promote rollup dependencies into workspace - remove unused build.js script * chore(repo): add build:watch using rollup * chore(repo): setup eslint * chore(adapter-nextjs): migrate to eslint * fix(repo): test-github-actions using js-yaml already removed API * chore(repo): add Code Spell Checker to recommended extension list * chore(repo): add formatOn actions to formattingToggle controlables * fix: not appending notification configs * chore(release): Publish [ci skip] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - [email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - [email protected] * Revert "chore(repo): use typescript 5.0.2 across workspace" (#12941) * Revert "chore(repo): use typescript 5.0.2 across workspace" This reverts commit e20782e. * chore(api-graphql): temporarily install rollup to package * fix(repo): rollup generated sourcemap has wrong src path (#12947) * fix(datastore): Treat head as optional to avoid errors (#12936) * fix(datastore): Treat head as optional to avoid errors * Add testing and fix follow-on issue * fix(api-graphql): wrong arguments for GET operation of a CPK model * fix: Remove special e2e treatment for validated tests (#12946) fix: Remove special integ treament for validated tests * fix(datastore): Limit docs integ test to one browser to improve stability (#12937) * fix(api-graphql): same results returned for queries on the same model with different selection set - caused by the incomplete GraphQL documents caching * Update branch to work with merged updates from main --------- Co-authored-by: israx <[email protected]> Co-authored-by: David McAfee <[email protected]> Co-authored-by: Jim Blanchard <[email protected]> Co-authored-by: aws-amplify-bot <[email protected]> Co-authored-by: Hui Zhao <[email protected]> Co-authored-by: AllanZhengYP <[email protected]> Co-authored-by: Hui Zhao <[email protected]> Co-authored-by: Ivan Artemiev <[email protected]> Co-authored-by: Aaron S <[email protected]> Co-authored-by: ManojNB <[email protected]> Co-authored-by: ManojNB <[email protected]> Co-authored-by: Francisco Rodriguez <[email protected]>
* chore(auth): debounce refreshAuthTokens (#12845) * chore: add debounce callback helper * chore: add unit tests * chore: debounce fetchAuthSession * chore: fix unit test * chore: fix bundle size limits * chore: update debounce logic * chore: update dedup logic * chore: debounce refreshAuthTokens * chore: fix bundle size * chore: address feedback * chore: fix unit test * chore: address feedback * chore: update yarn.lock * chore: address feedbak * fix(data): update DataStore to send correct Control Messages when starting (#12861) * chore(release): Publish [ci skip] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - [email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - [email protected] * chore(release): update API docs [ci skip] * chore: enable codecov (#12876) * docs(auth,analytics): adding in-line docs for public apis (#12882) * docs(auth,analytics): adding in-line docs for public apis * fix: unblock the max length lint * chore(react-native): use react-native 0.71.0 as the dev dep * fix: Default branch resolution when running E2E tests (#12910) * fix: Lambda auth config value (#12922) * chore: renable caching the package list in GH actions * chore: remove unused codecov package (has been deprecated) * feat(api): expose HTTP response from API errors (#12835) --------- Co-authored-by: Hui Zhao <[email protected]> Co-authored-by: Jim Blanchard <[email protected]> * chore: temporarily disable codecov GH action integration (#12928) * ci: run flaky data e2es without retry (#12758) * ci: run flaky data e2es without retry * only run on chrome * restore workflow --------- Co-authored-by: Aaron S <[email protected]> * fix(core): Amplify.configure dispatches Hub event with unparsed config object (#12930) * chore(repo): use typescript 5.0.2 across workspace * chore(repo): refactor tsconfig hierarchy - move the base tsconfig into the root of the workspace - unifying tsconfig tsconfig.build tsconfig.test and tsconfig.watch settings * chore(repo): promote rollup dependencies into workspace - remove unused build.js script * chore(repo): add build:watch using rollup * chore(repo): setup eslint * chore(adapter-nextjs): migrate to eslint * fix(repo): test-github-actions using js-yaml already removed API * chore(repo): add Code Spell Checker to recommended extension list * chore(repo): add formatOn actions to formattingToggle controlables * fix: not appending notification configs * chore(release): Publish [ci skip] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - [email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - @aws-amplify/[email protected] - [email protected] * Revert "chore(repo): use typescript 5.0.2 across workspace" (#12941) * Revert "chore(repo): use typescript 5.0.2 across workspace" This reverts commit e20782e. * chore(api-graphql): temporarily install rollup to package * fix(repo): rollup generated sourcemap has wrong src path (#12947) * fix(datastore): Treat head as optional to avoid errors (#12936) * fix(datastore): Treat head as optional to avoid errors * Add testing and fix follow-on issue * fix(api-graphql): wrong arguments for GET operation of a CPK model * fix: Remove special e2e treatment for validated tests (#12946) fix: Remove special integ treament for validated tests * fix(datastore): Limit docs integ test to one browser to improve stability (#12937) * fix(api-graphql): same results returned for queries on the same model with different selection set - caused by the incomplete GraphQL documents caching * Update branch to work with merged updates from main --------- Co-authored-by: israx <[email protected]> Co-authored-by: David McAfee <[email protected]> Co-authored-by: Jim Blanchard <[email protected]> Co-authored-by: aws-amplify-bot <[email protected]> Co-authored-by: Hui Zhao <[email protected]> Co-authored-by: AllanZhengYP <[email protected]> Co-authored-by: Hui Zhao <[email protected]> Co-authored-by: Ivan Artemiev <[email protected]> Co-authored-by: Aaron S <[email protected]> Co-authored-by: ManojNB <[email protected]> Co-authored-by: ManojNB <[email protected]> Co-authored-by: Francisco Rodriguez <[email protected]>
Description of changes
Expose the
error.response
accessor from the errors thrown by REST API handlers and GraphQL queries.Since the errors thrown by both REST APIs and GraphQL API share a same base error, We have to export the base
ApiError
from the core package.Here's the new error structure. Boxes in green are new.
Before
After
Issue #, if available
#12730
Description of how you validated changes
Checklist
yarn test
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.