-
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
fix(api-graphql): update error handling #13177
Conversation
e734eb0
to
46d2101
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.
Looks good to me. Thank you @HuiSF
46d2101
to
c6f26fa
Compare
@@ -2,7 +2,6 @@ | |||
"extends": "../../tsconfig.json", | |||
"compilerOptions": { | |||
"strictNullChecks": true, | |||
"baseUrl": ".", |
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 was add along with line 7-8 to resolve the type issues in the unit test suite. This baseUrl was actually not needed, and it caused an issue when IDE auto import symbols, it uses src/...
path instead of relative paths.
await amplify.Auth.fetchAuthSession() | ||
).tokens?.accessToken.toString(); | ||
|
||
if (!token) { | ||
throw new Error(GraphQLAuthError.NO_FEDERATED_JWT); |
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 specific error was being swallowed by the catch clause. Rearranged the flow here to ensure both errors in this block to be able to surface.
@@ -335,7 +335,7 @@ | |||
"name": "[API] generateClient (AppSync)", | |||
"path": "./dist/esm/api/index.mjs", | |||
"import": "{ generateClient }", | |||
"limit": "38.00 kB" | |||
"limit": "38.5 kB" |
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.
Mostly from the new messaging strings.
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.
Can we follow this up with a PR to defined-behavior
in the builder package(s) to solidify and make clear what our error handling contract looks like? (Both for .graphql()
and a sampling of the .models.*.*()
operations?)
- Use GraphApiError to create errors to be thrown * error message field remained the same as before * added recoverySuggestion field for each error case - Created createGraphQLResultWithError utility for rewrapping error into GraphQLResult format
c6f26fa
to
7087449
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.
Approving as admin on package.json - size change
chore(api-graphql): improve error handling - Use GraphApiError to create errors to be thrown * error message field remained the same as before * added recoverySuggestion field for each error case - Created createGraphQLResultWithError utility for rewrapping error into GraphQLResult format
Description of changes
See the commit message.
Issue #, if available
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.