I am working on a graphql + relay app served on top of hapi and would like to support requests to the graphql endpoint with the application/graphql
mime type.
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 do not see any place in my hapi server options where there is any explicit configuration for mime types and other than some terse documentation here.
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'
}
}
};
Does anybody else here have this kind of experience with hapi?
application/graphql
type does not even make it through to theparsePayload()
function. It is being thrown out with a 415 error long before that. – jerome