Closed chris-ramon closed 3 years ago
Why would you want to add result := executeQuery(r.URL.Query().Get("query"), schema.TodoSchema
still?
Just update your curl options for this demo:
curl \
-X POST \
-H "Content-Type: application/json" \
--data '{ "query": "{ todoList { id text } }" }' \
http://localhost:8080/graphql
Isnt it possible to have an example with POST only server? For example in another setup i learned i could do:
r := gin.New()
r.GET("/", playgroundHandler())
r.POST("/graphql", graphqlHandler())
r.GET("/.well-known/server-health", healthHandler())
and choose myself simple
Why would you want to add
result := executeQuery(r.URL.Query().Get("query"), schema.TodoSchema
still?
@maapteh FMHO we should keep the usage of GET
just for simplicity, the usage of the the correct HTTP verb should rely on lib users, if a secure protocol is a requirement then a proper secure protocol should be implemented like HTTPS.
Just update your curl options for this demo:
curl \ -X POST \ -H "Content-Type: application/json" \ --data '{ "query": "{ todoList { id text } }" }' \ http://localhost:8080/graphql
Planning to send a PR for adding examples/http-post
in order to show the usage of HTTP POST
, and yes we can continue to use curl
for consistency with examples/todo
to show the usage of the endpoint.
Then you dont open a GET option to get the results. All web clients use POST. By giving the options to GET it as well its superweird and users will think they can integrate like this as well. But maybe you like it to act like REST?
As mentioned above, FMHO lib users should decide which HTTP verb to use, we just use GET in the example for simplicity.
But nice work, i totally missed the option by default you can open playground and have POST working. This wasn't demonstrated in any example.
Yes, good call, I've created graphql-go/handler-examples/todo
for the matter.
Im wondering what happens if i turn it off (on production we turn off playground and introspection and deploy another instance with stuff on, which is only reachable internally).
Have a nice day
Using graphql-go/handler
the GraphQL Playground can be disable via the Playground: false
option, disabling it does not interfere the correct execution of the graphql-go/handler
itself.
Isnt it possible to have an example with POST only server? For example in another setup i learned i could do:
r := gin.New() r.GET("/", playgroundHandler()) r.POST("/graphql", graphqlHandler()) r.GET("/.well-known/server-health", healthHandler())
and choose myself simple
Yes, planning to send a PR for adding a new example: examples/http-post
for the matter after margining this PR.
Yes, planning to send a PR for adding a new example:
examples/http-post
for the matter after margining this PR.
^ Related PR for adding examples/http-post
: https://github.com/graphql-go/graphql/pull/575
Nice work Chris-Ramon!
Overview
Test plan
examples/todo
is working as expected:TodoSchema
works as expected usinggraphql-go/handler
: