graphql-go
graphql-go copied to clipboard
application/graphql support
Is there any support (or plans for it) for this content type for input? e.g. I expected the following request to work from the simple server example in the readme:
curl -XPOST -d 'query { hello }' -H "Content-Type:application/graphql" localhost:8080/query
But I get invalid character 'q' looking for beginning of value (since I assume it's just trying to parse json).
Take a look at the handler code here https://github.com/graph-gophers/graphql-go/blob/master/relay/relay.go#L50
Indeed the handler expects a JSON request with query and optional variables and operationName.
It should be trivial for you to build a custom handler and invoke:
h.Schema.Exec(r.Context(), params.Query, params.OperationName, params.Variables)
where params.Query comes from the request body.