Skip to content
Graffle is a work in progress. Learn more.

Abort

This example shows how to cancel requests using an AbortController signal.

ts

import { 
Graffle
} from 'graffle'
const
abortController
= new
AbortController
()
const
graffle
=
Graffle
.
create
().
transport
({
url
: `http://localhost:3000/graphql`,
}) const
resultPromise
=
graffle
.
transport
({
raw
: {
signal
:
abortController
.
signal
} })
.
gql
`
{ pokemon { name } } ` .
send
()
abortController
.
abort
()
const
result
= await
resultPromise
.
catch
((
error
: unknown) => (
error
as Error).
message
)
console.log(
result
)

Outputs

txt
This operation was aborted

Released under the MIT License.