-
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.
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
- Loading branch information
Showing
12 changed files
with
262 additions
and
120 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
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.