-
Notifications
You must be signed in to change notification settings - Fork 312
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: first class abort errors (#1061)
- Loading branch information
1 parent
1596711
commit 065418a
Showing
18 changed files
with
304 additions
and
146 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ coverage | |
tsconfig.vitest-temp.json | ||
website/.vitepress/dist | ||
website/.vitepress/cache | ||
legacy |
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 @@ | ||
'This operation was aborted' |
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,32 @@ | ||
/** | ||
* It is possible to cancel a request using an `AbortController` signal. | ||
*/ | ||
|
||
import { gql, Graffle } from '../src/entrypoints/main.js' | ||
import { publicGraphQLSchemaEndpoints, show } from './$helpers.js' | ||
|
||
const abortController = new AbortController() | ||
|
||
const graffle = Graffle.create({ | ||
schema: publicGraphQLSchemaEndpoints.SocialStudies, | ||
}) | ||
|
||
const resultPromise = graffle | ||
.with({ request: { signal: abortController.signal } }) | ||
.raw({ | ||
document: gql` | ||
{ | ||
countries { | ||
name | ||
} | ||
} | ||
`, | ||
}) | ||
|
||
abortController.abort() | ||
|
||
const result = await resultPromise.catch((error: unknown) => (error as Error).message) | ||
|
||
show(result) | ||
|
||
// todo .with(...) variant |
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
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
Oops, something went wrong.