Skip to content

Commit f700df0

Browse files
committed
Merge pull request #5 from graphql-go/update_package_name
Updated imports to `github.com/graphql-go/handler` and package to `handler`
2 parents db78bd4 + c8a06ef commit f700df0

File tree

5 files changed

+19
-29
lines changed

5 files changed

+19
-29
lines changed

CHANGELOG.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

README.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# graphql-go-handler
22

3-
Golang HTTP.Handler for [graphl-go](https://github.com/chris-ramon/graphql)
3+
Golang HTTP.Handler for [graphl-go](https://github.com/graphql-go/graphql)
44

55
### Notes:
66
This is based on alpha version of `graphql-go` and `graphql-relay-go`.
@@ -13,15 +13,15 @@ package main
1313

1414
import (
1515
"net/http"
16-
"github.com/sogko/graphql-go-handler"
16+
"github.com/graphql-go/handler"
1717
)
1818

1919
func main() {
2020

2121
// define GraphQL schema using relay library helpers
2222
schema := graphql.NewSchema(...)
2323

24-
h := gqlhandler.New(&gqlhandler.Config{
24+
h := handler.New(&handler.Config{
2525
Schema: schema,
2626
Pretty: true,
2727
})
@@ -68,14 +68,11 @@ depending on the provided `Content-Type` header.
6868

6969

7070
### Examples
71-
- [golang-graphql-playground](https://github.com/sogko/golang-graphql-playground)
71+
- [golang-graphql-playground](https://github.com/graphql-go/golang-graphql-playground)
7272
- [golang-relay-starter-kit](https://github.com/sogko/golang-relay-starter-kit)
7373
- [todomvc-relay-go](https://github.com/sogko/todomvc-relay-go)
7474

7575
### Test
7676
```bash
77-
$ go get github.com/sogko/graphql-go-handler
78-
$ go build && go test ./...
79-
```
80-
### Changelog
81-
For recent changes, see [Changelog](./CHANGELOG.md)
77+
$ go get github.com/graphql-go/handler
78+
$ go build && go test ./...

handler.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
package gqlhandler
1+
package handler
22

33
import (
44
"encoding/json"
55
"io/ioutil"
66
"net/http"
77
"strings"
88

9-
"github.com/chris-ramon/graphql"
109
"github.com/gorilla/schema"
10+
"github.com/graphql-go/graphql"
1111
"github.com/unrolled/render"
1212
)
1313

@@ -111,15 +111,13 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
111111
opts := getRequestOptions(r)
112112

113113
// execute graphql query
114-
resultChannel := make(chan *graphql.Result)
115114
params := graphql.Params{
116115
Schema: *h.Schema,
117116
RequestString: opts.Query,
118117
VariableValues: opts.Variables,
119118
OperationName: opts.OperationName,
120119
}
121-
go graphql.Graphql(params, resultChannel)
122-
result := <-resultChannel
120+
result := graphql.Graphql(params)
123121

124122
// render result
125123
h.render.JSON(w, http.StatusOK, result)

handler_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package gqlhandler_test
1+
package handler_test
22

33
import (
44
"encoding/json"
@@ -10,10 +10,10 @@ import (
1010
"strings"
1111
"testing"
1212

13-
"github.com/chris-ramon/graphql"
14-
"github.com/chris-ramon/graphql/testutil"
15-
"github.com/sogko/graphql-go-handler"
16-
"github.com/sogko/graphql-relay-go/examples/starwars"
13+
"github.com/graphql-go/graphql"
14+
"github.com/graphql-go/graphql/testutil"
15+
"github.com/graphql-go/handler"
16+
"github.com/graphql-go/relay/examples/starwars" // TODO: remove this dependency
1717
)
1818

1919
func decodeResponse(t *testing.T, recorder *httptest.ResponseRecorder) *graphql.Result {
@@ -32,7 +32,7 @@ func decodeResponse(t *testing.T, recorder *httptest.ResponseRecorder) *graphql.
3232
}
3333
return &target
3434
}
35-
func executeTest(t *testing.T, h *gqlhandler.Handler, req *http.Request) (*graphql.Result, *httptest.ResponseRecorder) {
35+
func executeTest(t *testing.T, h *handler.Handler, req *http.Request) (*graphql.Result, *httptest.ResponseRecorder) {
3636
resp := httptest.NewRecorder()
3737
h.ServeHTTP(resp, req)
3838
result := decodeResponse(t, resp)
@@ -52,7 +52,7 @@ func TestHandler_BasicQuery(t *testing.T) {
5252
queryString := `query=query RebelsShipsQuery { rebels { id, name } }`
5353
req, _ := http.NewRequest("GET", fmt.Sprintf("/graphql?%v", queryString), nil)
5454

55-
h := gqlhandler.New(&gqlhandler.Config{
55+
h := handler.New(&handler.Config{
5656
Schema: &starwars.Schema,
5757
Pretty: true,
5858
})
@@ -79,6 +79,6 @@ func TestHandler_Params_NilParams(t *testing.T) {
7979
}
8080
t.Fatalf("expected to panic, did not panic")
8181
}()
82-
_ = gqlhandler.New(nil)
82+
_ = handler.New(nil)
8383

8484
}

request_options_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package gqlhandler
1+
package handler
22

33
import (
44
"bytes"
@@ -8,7 +8,7 @@ import (
88
"reflect"
99
"testing"
1010

11-
"github.com/chris-ramon/graphql/testutil"
11+
"github.com/graphql-go/graphql/testutil"
1212
)
1313

1414
func TestRequestOptions_GET_BasicQueryString(t *testing.T) {

0 commit comments

Comments
 (0)