forked from graph-gophers/graphql-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from tribunadigital/update-upstream-v1.3.0
Update upstream v1.3.0
- Loading branch information
Showing
32 changed files
with
1,544 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
run: | ||
timeout: 5m | ||
|
||
linters-settings: | ||
gofmt: | ||
simplify: true | ||
govet: | ||
check-shadowing: true | ||
enable-all: true | ||
disable: | ||
- fieldalignment | ||
- deepequalerrors # remove later | ||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
- deadcode | ||
- gofmt | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- exportloopref | ||
- structcheck | ||
- staticcheck | ||
- unconvert | ||
- unused | ||
- varcheck | ||
- misspell | ||
- goimports | ||
|
||
issues: | ||
exclude-rules: | ||
- linters: | ||
- unused | ||
path: "graphql_test.go" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
version: v1.0 | ||
name: Go | ||
agent: | ||
machine: | ||
type: e1-standard-2 | ||
os_image: ubuntu2004 | ||
blocks: | ||
- name: Style Check | ||
task: | ||
jobs: | ||
- name: fmt | ||
commands: | ||
- sem-version go 1.17 | ||
- checkout | ||
- ./scripts/golangci_install.sh -b $(go env GOPATH)/bin v1.42.1 | ||
- export PATH=$(go env GOPATH)/bin:$PATH | ||
- golangci-lint run ./... | ||
|
||
- name: Test & Build | ||
task: | ||
prologue: | ||
commands: | ||
- sem-version go 1.17 | ||
- export PATH=$(go env GOPATH)/bin:$PATH | ||
- checkout | ||
- go version | ||
|
||
jobs: | ||
- name: Test | ||
commands: | ||
- go test ./... | ||
|
||
- name: Build | ||
commands: | ||
- go build -v . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
CHANGELOG | ||
|
||
[v1.1.0](https://github.com/graph-gophers/graphql-go/releases/tag/v1.1.0) Release v1.1.0 | ||
* [FEATURE] Add types package #437 | ||
* [FEATURE] Expose `packer.Unmarshaler` as `decode.Unmarshaler` to the public #450 | ||
* [FEATURE] Add location fields to type definitions #454 | ||
* [FEATURE] `errors.Errorf` preserves original error similar to `fmt.Errorf` #456 | ||
* [BUGFIX] Fix duplicated __typename in response (fixes #369) #443 | ||
|
||
[v1.0.0](https://github.com/graph-gophers/graphql-go/releases/tag/v1.0.0) Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package errors | ||
|
||
import ( | ||
"context" | ||
) | ||
|
||
// PanicHandler is the interface used to create custom panic errors that occur during query execution | ||
type PanicHandler interface { | ||
MakePanicError(ctx context.Context, value interface{}) *QueryError | ||
} | ||
|
||
// DefaultPanicHandler is the default PanicHandler | ||
type DefaultPanicHandler struct{} | ||
|
||
// MakePanicError creates a new QueryError from a panic that occurred during execution | ||
func (h *DefaultPanicHandler) MakePanicError(ctx context.Context, value interface{}) *QueryError { | ||
return Errorf("panic occurred: %v", value) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package errors | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
) | ||
|
||
func TestDefaultPanicHandler(t *testing.T) { | ||
handler := &DefaultPanicHandler{} | ||
qErr := handler.MakePanicError(context.Background(), "foo") | ||
if qErr == nil { | ||
t.Fatal("Panic error must not be nil") | ||
} | ||
const ( | ||
expectedMessage = "panic occurred: foo" | ||
expectedError = "graphql: " + expectedMessage | ||
) | ||
if qErr.Error() != expectedError { | ||
t.Errorf("Unexpected panic error message: %q != %q", qErr.Error(), expectedError) | ||
} | ||
if qErr.Message != expectedMessage { | ||
t.Errorf("Unexpected panic QueryError.Message: %q != %q", qErr.Message, expectedMessage) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"net/http" | ||
|
||
graphql "github.com/tribunadigital/graphql-go" | ||
"github.com/tribunadigital/graphql-go/example/scalar_map/types" | ||
"github.com/tribunadigital/graphql-go/relay" | ||
) | ||
|
||
type Args struct { | ||
Name string | ||
Data types.Map | ||
} | ||
|
||
type mutation struct{} | ||
|
||
func (_ *mutation) Hello(args Args) string { | ||
|
||
fmt.Println(args) | ||
|
||
return "Args accept!" | ||
} | ||
|
||
func main() { | ||
s := ` | ||
scalar Map | ||
type Query {} | ||
type Mutation { | ||
hello( | ||
name: String! | ||
data: Map! | ||
): String! | ||
} | ||
` | ||
schema := graphql.MustParseSchema(s, &mutation{}) | ||
http.Handle("/query", &relay.Handler{Schema: schema}) | ||
|
||
log.Println("Listen in port :8080") | ||
log.Fatal(http.ListenAndServe(":8080", nil)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package types | ||
|
||
import "fmt" | ||
|
||
type Map map[string]interface{} | ||
|
||
func (Map) ImplementsGraphQLType(name string) bool { | ||
return name == "Map" | ||
} | ||
|
||
func (j *Map) UnmarshalGraphQL(input interface{}) error { | ||
json, ok := input.(map[string]interface{}) | ||
if !ok { | ||
return fmt.Errorf("wrong type") | ||
} | ||
|
||
*j = json | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.