hapi-graphql icon indicating copy to clipboard operation
hapi-graphql copied to clipboard

Server responds with 415 on application/graphql

Open jeromecovington opened this issue 10 years ago • 1 comments

I am working on a graphql + relay app served on top of hapi and have ported your code to my application.

Here you can see me sending POST requests to the graphql endpoint.

~> curl -X POST --header "Content-Type:application/json" -d '{"query":"{content(id:\"13381672\"){title,id}}"}' http://127.0.0.1:8000/graphql
{"data":{"content":{"title":"Example Title","id":"13381672"}}}
~> curl -X POST --header "Content-Type:application/graphql" -d '{"query":"{content(id:\"13381672\"){title,id}}"}' http://127.0.0.1:8000/graphql
{"statusCode":415,"error":"Unsupported Media Type"}

I have set up an options mime configuration as per the below, passing options into the server instantiation, but I am still seeing the "Unsupported Media Type" error.

options.mime = {
  override: {
    'application/graphql': {
      charset: 'UTF-8',
      compressible: true,
      type: 'application/graphql'
    }
  }
};

I don't see any mime configuration here. Is that an oversight, or am I missing something else?

jeromecovington avatar Jan 07 '16 14:01 jeromecovington

Just came across this post with a google search.

The below works for me: curl -X POST -H "Content-Type: application/json" -d '{"query":"{person(firstname:\"billy\"){lastname}}"}' http://127.0.0.1:8000/graphql

Checkout blow file for an example: https://github.com/zoe-1/graphi/blob/master/example.js

Checkout Graphi

zoe-1 avatar Dec 27 '17 03:12 zoe-1