mirror of
https://github.com/schollz/cowyo.git
synced 2023-08-10 21:13:00 +03:00
update dependencies
This commit is contained in:
6
vendor/github.com/shurcooL/graphql/example/graphqldev/main.go
generated
vendored
6
vendor/github.com/shurcooL/graphql/example/graphqldev/main.go
generated
vendored
@@ -14,9 +14,9 @@ import (
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
|
||||
graphqlserver "github.com/neelance/graphql-go"
|
||||
"github.com/neelance/graphql-go/example/starwars"
|
||||
"github.com/neelance/graphql-go/relay"
|
||||
graphqlserver "github.com/graph-gophers/graphql-go"
|
||||
"github.com/graph-gophers/graphql-go/example/starwars"
|
||||
"github.com/graph-gophers/graphql-go/relay"
|
||||
"github.com/shurcooL/graphql"
|
||||
)
|
||||
|
||||
|
||||
7
vendor/github.com/shurcooL/graphql/graphql.go
generated
vendored
7
vendor/github.com/shurcooL/graphql/graphql.go
generated
vendored
@@ -81,11 +81,14 @@ func (c *Client) do(ctx context.Context, op operationType, v interface{}, variab
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = jsonutil.UnmarshalGraphQL(out.Data, v)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(out.Errors) > 0 {
|
||||
return out.Errors
|
||||
}
|
||||
err = jsonutil.UnmarshalGraphQL(out.Data, v)
|
||||
return err
|
||||
return nil
|
||||
}
|
||||
|
||||
// errors represents the "errors" array in a response from a GraphQL server.
|
||||
|
||||
83
vendor/github.com/shurcooL/graphql/graphql_test.go
generated
vendored
Normal file
83
vendor/github.com/shurcooL/graphql/graphql_test.go
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
package graphql_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/shurcooL/graphql"
|
||||
)
|
||||
|
||||
func TestClient_Query_partialResultWithErrorResponse(t *testing.T) {
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/graphql", func(w http.ResponseWriter, req *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
mustWrite(w, `{
|
||||
"data": {
|
||||
"node1": {
|
||||
"id": "MDEyOklzc3VlQ29tbWVudDE2OTQwNzk0Ng=="
|
||||
},
|
||||
"node2": null
|
||||
},
|
||||
"errors": [
|
||||
{
|
||||
"message": "Could not resolve to a node with the global id of 'NotExist'",
|
||||
"type": "NOT_FOUND",
|
||||
"path": [
|
||||
"node2"
|
||||
],
|
||||
"locations": [
|
||||
{
|
||||
"line": 10,
|
||||
"column": 4
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}`)
|
||||
})
|
||||
client := graphql.NewClient("/graphql", &http.Client{Transport: localRoundTripper{handler: mux}})
|
||||
|
||||
var q struct {
|
||||
Node1 *struct {
|
||||
ID graphql.ID
|
||||
} `graphql:"node1: node(id: \"MDEyOklzc3VlQ29tbWVudDE2OTQwNzk0Ng==\")"`
|
||||
Node2 *struct {
|
||||
ID graphql.ID
|
||||
} `graphql:"node2: node(id: \"NotExist\")"`
|
||||
}
|
||||
err := client.Query(context.Background(), &q, nil)
|
||||
if err == nil {
|
||||
t.Fatal("got error: nil, want: non-nil")
|
||||
}
|
||||
if got, want := err.Error(), "Could not resolve to a node with the global id of 'NotExist'"; got != want {
|
||||
t.Errorf("got error: %v, want: %v", got, want)
|
||||
}
|
||||
if q.Node1 == nil || q.Node1.ID != "MDEyOklzc3VlQ29tbWVudDE2OTQwNzk0Ng==" {
|
||||
t.Errorf("got wrong q.Node1: %v", q.Node1)
|
||||
}
|
||||
if q.Node2 != nil {
|
||||
t.Errorf("got non-nil q.Node2: %v, want: nil", *q.Node2)
|
||||
}
|
||||
}
|
||||
|
||||
// localRoundTripper is an http.RoundTripper that executes HTTP transactions
|
||||
// by using handler directly, instead of going over an HTTP connection.
|
||||
type localRoundTripper struct {
|
||||
handler http.Handler
|
||||
}
|
||||
|
||||
func (l localRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
w := httptest.NewRecorder()
|
||||
l.handler.ServeHTTP(w, req)
|
||||
return w.Result(), nil
|
||||
}
|
||||
|
||||
func mustWrite(w io.Writer, s string) {
|
||||
_, err := io.WriteString(w, s)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user