-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: expose error handling in graphql request service (#2386)
- Loading branch information
1 parent
04963be
commit 010916f
Showing
6 changed files
with
79 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export class GraphqlExecutionError extends Error { | ||
public constructor(public readonly message: string, public readonly requestString: string) { | ||
super(message); | ||
} | ||
} |
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,10 @@ | ||
import { GraphqlExecutionError } from './graphql-execution-error'; | ||
import { GraphQlRequest } from './graphql-request.api'; | ||
|
||
export class GraphqlRequestError extends GraphqlExecutionError { | ||
public constructor(public readonly error: GraphqlExecutionError, public readonly request: GraphQlRequest) { | ||
super(error.message, error.requestString); | ||
this.name = error.name; | ||
this.stack = error.stack; | ||
} | ||
} |
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,22 @@ | ||
import { GraphQlHandler } from './graphql-config'; | ||
|
||
export const enum GraphQlResultStatus { | ||
Success = 'SUCCESS', | ||
Error = 'ERROR' | ||
} | ||
|
||
export type GraphQlRequest = unknown; | ||
|
||
export type RequestTypeForHandler<T extends GraphQlHandler<unknown, unknown>> = T extends GraphQlHandler< | ||
infer TRequest, | ||
unknown | ||
> | ||
? TRequest | ||
: never; | ||
|
||
export type ResponseTypeForHandler<T extends GraphQlHandler<unknown, unknown>> = T extends GraphQlHandler< | ||
unknown, | ||
infer TResponse | ||
> | ||
? TResponse | ||
: never; |
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