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

Slot Fetch

This example shows how to use the fetch slot on exchange hook.

ts
import { 
Graffle
} from 'graffle'
const
graffle
=
Graffle
.
create
({
schema
: `https://countries.trevorblades.com/graphql` })
.
anyware
(async ({
exchange
}) => {
return await
exchange
({
using
: {
fetch
: () => {
return new
Response
(
JSON
.
stringify
({
data
: {
continents
: [{
name
: `Earthsea` }] } }))
}, }, }) }) const
result
= await
graffle
.
rawString
({
document
: `query { continents { name } }`,
})
console
.
log
(
result
)

Outputs

txt
{ continents: [ { name: 'Earthsea' } ] }

Released under the MIT License.