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 #4 from tribunadigital/update-upstream-v1.1.0
Update upstream v1.1.0
- Loading branch information
Showing
47 changed files
with
1,816 additions
and
1,148 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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
/.idea | ||
/.vscode | ||
/internal/validation/testdata/graphql-js | ||
/internal/validation/testdata/node_modules | ||
/vendor |
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,3 @@ | ||
CHANGELOG | ||
|
||
[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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package decode | ||
|
||
// Unmarshaler defines the api of Go types mapped to custom GraphQL scalar types | ||
type Unmarshaler interface { | ||
// ImplementsGraphQLType maps the implementing custom Go type | ||
// to the GraphQL scalar type in the schema. | ||
ImplementsGraphQLType(name string) bool | ||
// UnmarshalGraphQL is the custom unmarshaler for the implementing type | ||
// | ||
// This function will be called whenever you use the | ||
// custom GraphQL scalar type as an input | ||
UnmarshalGraphQL(input interface{}) error | ||
} |
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,55 @@ | ||
package errors | ||
|
||
import ( | ||
"io" | ||
"testing" | ||
) | ||
|
||
// Is is simplified facsimile of the go 1.13 errors.Is to ensure QueryError is compatible | ||
func Is(err, target error) bool { | ||
for err != nil { | ||
if target == err { | ||
return true | ||
} | ||
|
||
switch e := err.(type) { | ||
case interface{ Unwrap() error }: | ||
err = e.Unwrap() | ||
default: | ||
break | ||
} | ||
} | ||
return false | ||
} | ||
|
||
func TestErrorf(t *testing.T) { | ||
cause := io.EOF | ||
|
||
t.Run("wrap error", func(t *testing.T) { | ||
err := Errorf("boom: %v", cause) | ||
if !Is(err, cause) { | ||
t.Fatalf("expected errors.Is to return true") | ||
} | ||
}) | ||
|
||
t.Run("handles nil", func(t *testing.T) { | ||
var err *QueryError | ||
if Is(err, cause) { | ||
t.Fatalf("expected errors.Is to return false") | ||
} | ||
}) | ||
|
||
t.Run("handle no arguments", func(t *testing.T) { | ||
err := Errorf("boom") | ||
if Is(err, cause) { | ||
t.Fatalf("expected errors.Is to return false") | ||
} | ||
}) | ||
|
||
t.Run("handle non-error argument arguments", func(t *testing.T) { | ||
err := Errorf("boom: %v", "shaka") | ||
if Is(err, cause) { | ||
t.Fatalf("expected errors.Is to return false") | ||
} | ||
}) | ||
} |
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
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 |
---|---|---|
@@ -1,32 +1,18 @@ | ||
package common | ||
|
||
type Directive struct { | ||
Name Ident | ||
Args ArgumentList | ||
} | ||
import "github.com/tribunadigital/graphql-go/types" | ||
|
||
func ParseDirectives(l *Lexer) DirectiveList { | ||
var directives DirectiveList | ||
func ParseDirectives(l *Lexer) types.DirectiveList { | ||
var directives types.DirectiveList | ||
for l.Peek() == '@' { | ||
l.ConsumeToken('@') | ||
d := &Directive{} | ||
d := &types.Directive{} | ||
d.Name = l.ConsumeIdentWithLoc() | ||
d.Name.Loc.Column-- | ||
if l.Peek() == '(' { | ||
d.Args = ParseArguments(l) | ||
d.Arguments = ParseArgumentList(l) | ||
} | ||
directives = append(directives, d) | ||
} | ||
return directives | ||
} | ||
|
||
type DirectiveList []*Directive | ||
|
||
func (l DirectiveList) Get(name string) *Directive { | ||
for _, d := range l { | ||
if d.Name.Name == name { | ||
return d | ||
} | ||
} | ||
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.