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

Slot Body

This example shows how to use the body slot on the pack hook.

ts
import { 
Graffle
} from 'graffle'
const
graffle
=
Graffle
.
create
({
schema
: `http://localhost:3000/graphql` })
.
anyware
(async ({
pack
}) => {
return await
pack
({
using
: {
body
: (
graphqlRequest
) => {
return
JSON
.
stringify
({
...
graphqlRequest
,
operationName
: `trainers`,
}) }, }, }) }) const
result
= await
graffle
.
gql
`
query pokemon { trainers { name } } query trainers { pokemon { name } } `.
send
(`pokemon`)
console.log(
result
)

Outputs

txt
{
  pokemon: [
    { name: 'Pikachu' },
    { name: 'Charizard' },
    { name: 'Squirtle' },
    { name: 'Bulbasaur' },
    { name: 'Caterpie' },
    { name: 'Weedle' }
  ]
}

Released under the MIT License.