Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

application/graphql support #232

Open
zombor opened this issue Jun 26, 2018 · 1 comment
Open

application/graphql support #232

zombor opened this issue Jun 26, 2018 · 1 comment

Comments

@zombor
Copy link

zombor commented Jun 26, 2018

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).

@pavelnikolov
Copy link
Member

pavelnikolov commented Jun 27, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants