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

Raw

This example shows how to use the raw configuration of transport configuration to easily access low-level RequestInit configuration.

ts

import { 
Graffle
} from 'graffle'
const
graffle
=
Graffle
.
create
()
.
transport
({
url
: `http://localhost:3000/graphql`,
raw
: {
mode
: `cors`,
}, }) .
anyware
(({
exchange
}) => {
console.log(
exchange
.
input
.
request
)
return
exchange
()
}) await
graffle
.
gql
`{ pokemons { name } }`.
send
()

Outputs

txt
{
  methodMode: 'post',
  headers: Headers {
    accept: 'application/graphql-response+json; charset=utf-8, application/json; charset=utf-8',
    'content-type': 'application/json'
  },
  mode: 'cors',
  method: 'post',
  url: {
    _tag: 'url',
    value: URL {
      href: 'http://localhost:3000/graphql',
      origin: 'http://localhost:3000',
      protocol: 'http:',
      username: '',
      password: '',
      host: 'localhost:3000',
      hostname: 'localhost',
      port: '3000',
      pathname: '/graphql',
      search: '',
      searchParams: URLSearchParams {},
      hash: ''
    }
  },
  body: '{"query":"{ pokemons { name } }"}'
}

Released under the MIT License.