Skip to content

Commit 4cbeb43

Browse files
exposing getarguments function
1 parent d6d3353 commit 4cbeb43

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

directives.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package tools
22

33
import (
44
"context"
5+
"fmt"
56

67
"github.com/graphql-go/graphql"
78
"github.com/graphql-go/graphql/language/ast"
@@ -197,7 +198,7 @@ func (c *registry) applyDirectives(p applyDirectiveParams) error {
197198

198199
args, err := GetArgumentValues(directive.Args, def.Arguments, map[string]interface{}{})
199200
if err != nil {
200-
return err
201+
return fmt.Errorf("applyDirective %v error: %s", p.config, err)
201202
}
202203

203204
switch p.config.(type) {

values.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ func GetArgumentValues(argDefs []*graphql.Argument, argASTs []*ast.Argument, var
4242
typeString := argDef.Type.String()
4343
isNonNull := typeString[len(typeString)-1:] == "!"
4444
if isNonNull && isNullish(value) {
45-
return nil, fmt.Errorf("graphql input %q cannot be null", name)
45+
locs := []string{}
46+
47+
for _, a := range argASTs {
48+
locs = append(locs, fmt.Sprintf("%d:%d", a.Loc.Start, a.Loc.End))
49+
}
50+
return nil, fmt.Errorf(`graphql input %q @ %q cannot be null`, name, locs)
4651
}
4752

4853
if !isNullish(value) {

0 commit comments

Comments
 (0)