Skip to content

Commit

Permalink
More minor tweaks
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Coffman <steve@khanacademy.org>
  • Loading branch information
StevenACoffman committed Sep 7, 2023
1 parent 77ba251 commit 4cbcf03
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
3 changes: 3 additions & 0 deletions ast/path.go
Expand Up @@ -18,6 +18,9 @@ var _ PathElement = PathIndex(0)
var _ PathElement = PathName("")

func (path *Path) String() string {
if path == nil {
return ""
}
var str bytes.Buffer
for i, v := range *path {
switch v := v.(type) {
Expand Down
7 changes: 7 additions & 0 deletions gqlerror/error.go
Expand Up @@ -72,6 +72,13 @@ func (err *Error) Unwrap() error {
return err.err
}

func (err *Error) AsError() error {
if err == nil {
return nil
}
return err
}

func (errs List) Error() string {
var buf bytes.Buffer
for _, err := range errs {
Expand Down
24 changes: 12 additions & 12 deletions parser/schema.go
Expand Up @@ -6,6 +6,18 @@ import (
"github.com/vektah/gqlparser/v2/lexer"
)

func ParseSchemas(inputs ...*Source) (*SchemaDocument, error) {
sd := &SchemaDocument{}
for _, input := range inputs {
inputAst, err := ParseSchema(input)
if err != nil {
return nil, err
}
sd.Merge(inputAst)
}
return sd, nil
}

func ParseSchema(source *Source) (*SchemaDocument, error) {
p := parser{
lexer: lexer.New(source),
Expand All @@ -25,18 +37,6 @@ func ParseSchema(source *Source) (*SchemaDocument, error) {
return sd, nil
}

func ParseSchemas(inputs ...*Source) (*SchemaDocument, error) {
sd := &SchemaDocument{}
for _, input := range inputs {
inputAst, err := ParseSchema(input)
if err != nil {
return nil, err
}
sd.Merge(inputAst)
}
return sd, nil
}

func (p *parser) parseSchemaDocument() *SchemaDocument {
var doc SchemaDocument
doc.Position = p.peekPos()
Expand Down

0 comments on commit 4cbcf03

Please sign in to comment.