Slot Fetch
This example shows how to use the fetch
slot on exchange
hook.
ts
import { Graffle } from 'graffle'
const graffle = Graffle
.create({ schema: `http://localhost:3000/graphql` })
.anyware(async ({ exchange }) => {
return await exchange({
using: {
fetch: () => {
return new Response(JSON.stringify({ data: { trainers: [{ name: `Jason` }] } }))
},
},
})
})
const result = await graffle.gql`
query {
trainers {
name
}
}
`.send()
console.log(result)
Outputs
txt
{ trainers: [ { name: 'Jason' } ] }