jasonkuhrt / graphql-request

Minimal GraphQL client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Graffle helper functions

jasonkuhrt opened this issue · comments

Perceived Problem

  • GQLR library exposes a static import request
  • GQLR has no concept of executing against a schema
  • Graffle would do well to make migration easy

Ideas / Proposed Solution(s)

  • Add a request export
  • Add a execute export
import { execute, request, Graffle } from 'graffle'


const graffle1 = Graffle.create({
  schema: new URL('https://...'),
  headers: {...},
})

await graffle1.rawOrThrow(`GraphQL Document Here`, {
  headers: {...},
  variables: {...}
})

await request({
  schema: new URL('https://...'),
  headers: {...},
  document: `GraphQL Document Here`,
  variables: {...},
})

const graffle2 = Graffle.create({ schema: someSchema })

await graffle2.rawOrThrow(`GraphQL Document Here`)

await execute({
  schema: someSchema
  document: `GraphQL Document Here`,
  headers: {...},
})