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

Transport Memory

This example shows how you can send requests against an in-memory GraphQL schema instead of one hosted over HTTP.

ts
import { 
GraphQLObjectType
,
GraphQLSchema
,
GraphQLString
} from 'graphql'
import {
Graffle
} from 'graffle'
const
schema
= new
GraphQLSchema
({
query
: new
GraphQLObjectType
({
name
: `Query`,
fields
: {
foo
: {
type
:
GraphQLString
,
resolve
: () => `bar`,
}, }, }), }) const
graffle
=
Graffle
.
create
({
schema
})
const
data
= await
graffle
.
rawString
({
document
: `{ foo }` })
console
.
log
(
data
)

Outputs

json
{
  "foo": "bar"
}

Released under the MIT License.