-
Notifications
You must be signed in to change notification settings - Fork 842
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
examples/todo: extracts TodoSchema #574
Conversation
So TodoSchema can be re-use for demo purposes
Why would you want to add Just update your curl options for this demo:
Isnt it possible to have an example with POST only server? For example in another setup i learned i could do:
and choose myself simple |
@@ -207,7 +33,7 @@ func executeQuery(query string, schema graphql.Schema) *graphql.Result { | |||
|
|||
func main() { | |||
http.HandleFunc("/graphql", func(w http.ResponseWriter, r *http.Request) { | |||
result := executeQuery(r.URL.Query().Get("query"), schema) | |||
result := executeQuery(r.URL.Query().Get("query"), schema.TodoSchema) | |||
json.NewEncoder(w).Encode(result) | |||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not utilising your sample given:
h := handler.New(&handler.Config{
Schema: &schema.TodoSchema,
Pretty: true,
GraphiQL: false,
Playground: true,
})
http.Handle("/graphql", h)
log.Println("server running on port :8080")
http.ListenAndServe(":8080", nil)
why not take this static out of the example? and why still give GET example. Bu showcasing POST you close the open Issue #420 and its shown by example it can do it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maapteh yes, the given example just shows how to connect handle.New
with schema.TodoSchema
, in order to show this kind of examples I've created a new repository graphql-go/handler-examples
which we can use to point lib users to in order to show graphql-go/handler
related examples.
I think is ok to keep the usage of GET
in examples/todo
for simplicity of the example itself.
In order to showcase the usage of POST
, planning to send a PR for adding a new example examples/http-post
which will be based from your PR#573.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^ Related PR for adding examples/http-post
: #575
@maapteh FMHO we should keep the usage of
Planning to send a PR for adding
As mentioned above, FMHO lib users should decide which HTTP verb to use, we just use GET in the example for simplicity.
Yes, good call, I've created
Using |
Yes, planning to send a PR for adding a new example: |
^ Related PR for adding |
Nice work Chris-Ramon! |
Overview
Test plan
examples/todo
is working as expected:TodoSchema
works as expected usinggraphql-go/handler
: