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

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
({
schema
: `https://countries.trevorblades.com/graphql`,
transport
: {
methodMode
: `getReads` } })
.
anyware
(async ({
pack
}) => {
return await
pack
({
using
: {
searchParams
: (
graphqlRequest
) => {
return {
query
:
graphqlRequest
.
query
,
operationName
: `queryContinents`,
} }, }, }) }) const
result
= await
graffle
.
rawString
({
document
: `
query queryContinents { continents { name } } query queryCountries { countries { name } } `,
operationName
: `queryCountries`,
})
console
.
log
(
result
)

Outputs

txt
{
  continents: [
    { name: 'Africa' },
    { name: 'Antarctica' },
    { name: 'Asia' },
    { name: 'Europe' },
    { name: 'North America' },
    { name: 'Oceania' },
    { name: 'South America' }
  ]
}

Released under the MIT License.