Slot Search Params
This example shows how to use the searchParams
slot on the pack
hook.
ts
import { Graffle } from 'graffle'
const graffle = Graffle
.create()
.transport({ url: `http://localhost:3000/graphql`, methodMode: `getReads` })
.anyware(async ({ pack }) => {
return await pack({
using: {
searchParams: (graphqlRequest) => {
return {
query: graphqlRequest.query,
operationName: `getPokemons`,
}
},
},
})
})
const result = await graffle.gql`
query getTrainers {
trainers { name }
}
query getPokemons {
pokemons { name }
}
`
.send(`getTrainers`)
console.log(result)
Outputs
txt
{
pokemons: [
{ name: 'Pikachu' },
{ name: 'Charizard' },
{ name: 'Squirtle' },
{ name: 'Bulbasaur' },
{ name: 'Caterpie' },
{ name: 'Weedle' }
]
}