micro-graphql-react icon indicating copy to clipboard operation
micro-graphql-react copied to clipboard

add support for POST (#75)

Open gummikonsumer opened this issue 1 year ago • 0 comments

Resolves #75

The tests seem sort of hard to add a new client to, so I skipped it, but I implemented the actual functionality. Additionally, https://mylibrary.io/graphql-public seems down, and I can't get the demo-project to build as it is. This is a pretty simple change, though, and I tested with this code:

import { Client, setDefaultClient } from './dist/index.min.js'

const client = new Client({
  endpoint: 'http://localhost:3000/api',
  fetchOptions: { method: 'POST' }
})

setDefaultClient(client)

const QUERY_TEST = `
{
  hello(name: "David")
}
`

console.log(await client.runQuery(QUERY_TEST, {}))

on a POST-only graphql server, I get this:

{ data: { hello: 'Hello David' } }

gummikonsumer avatar Jun 22 '24 02:06 gummikonsumer