Skip to content

Latest commit

 

History

History

node-graphql

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Node GraphQL

GraphQL server with CORS.

Setup

$ yarn

Deploy

$ up

Usage

With curl:

$ curl -d '{ "query": "{ pet(id: 0) { name }}" }' `up url`?pretty

With fetch() in the browser:

const body = JSON.stringify({
  query: `query {
    pet(id: 2) {
      name
    }
  }`
})

const res = await fetch('http://localhost:3000', {
  headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
  method: 'POST',
  body
})

console.log(res)
console.log(await res.json())

See the CORS second of the documentation for details.