Skip to content

Commit

Permalink
Merge pull request #216 from WindomZ/master
Browse files Browse the repository at this point in the history
Examples: use '.Get("query")' instead of '["query"][0]'
  • Loading branch information
chris-ramon authored Jul 18, 2017
2 parents 3e619b6 + b2b9069 commit 096f5bc
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/context/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func graphqlHandler(w http.ResponseWriter, r *http.Request) {
}{1, "cool user"}
result := graphql.Do(graphql.Params{
Schema: Schema,
RequestString: r.URL.Query()["query"][0],
RequestString: r.URL.Query().Get("query"),
Context: context.WithValue(context.Background(), "currentUser", user),
})
if len(result.Errors) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion examples/http/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func main() {
_ = importJSONDataFromFile("data.json", &data)

http.HandleFunc("/graphql", func(w http.ResponseWriter, r *http.Request) {
result := executeQuery(r.URL.Query()["query"][0], schema)
result := executeQuery(r.URL.Query().Get("query"), schema)
json.NewEncoder(w).Encode(result)
})

Expand Down
2 changes: 1 addition & 1 deletion examples/httpdynamic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func main() {
}

http.HandleFunc("/graphql", func(w http.ResponseWriter, r *http.Request) {
result := executeQuery(r.URL.Query()["query"][0], schema)
result := executeQuery(r.URL.Query().Get("query"), schema)
json.NewEncoder(w).Encode(result)
})

Expand Down
2 changes: 1 addition & 1 deletion examples/star-wars/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

func main() {
http.HandleFunc("/graphql", func(w http.ResponseWriter, r *http.Request) {
query := r.URL.Query()["query"][0]
query := r.URL.Query().Get("query")
result := graphql.Do(graphql.Params{
Schema: testutil.StarWarsSchema,
RequestString: query,
Expand Down
2 changes: 1 addition & 1 deletion examples/todo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,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()["query"][0], schema)
result := executeQuery(r.URL.Query().Get("query"), schema)
json.NewEncoder(w).Encode(result)
})
// Serve static files
Expand Down

0 comments on commit 096f5bc

Please sign in to comment.