-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(api-graphql): update error handling
- Now throw the catastrophic errors thrown from the `post()` API 1. Network connection or CORS caused Network error 2. The cancellation error - Now throw an error when there is no endpoint configured - Using `GraphQLApiError` to throw Auth related errors instead of `Error`
- Loading branch information
Showing
14 changed files
with
269 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
packages/api-graphql/src/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { GraphQLResult } from '../../../types'; | ||
|
||
export function isGraphQLResponseWithErrors( | ||
response: unknown, | ||
): response is GraphQLResult { | ||
if (!response) { | ||
return false; | ||
} | ||
const r = response as GraphQLResult; | ||
|
||
return Array.isArray(r.errors) && r.errors.length > 0; | ||
} |
Oops, something went wrong.