vektah / gqlparser

A port of the parser from graphql-js into golang
MIT License
498 stars 123 forks source link

fix : returning error instead of *gqlError.Error #234

Closed schafle closed 2 years ago

schafle commented 2 years ago

Related Issue:

https://github.com/vektah/gqlparser/issues/99

Background

gqlparser functions are returning nil but the return type is *gqlrrror.Error.

This is how the code looks like before my change: https://github.com/vektah/gqlparser/blob/master/parser/schema.go#L9

func ParseSchema(source *Source) (*SchemaDocument, *gqlerror.Error) {
   .
   .
   .
    return ast, nil
}

The problem is while using this code, err != nil doesn't work since err is actually not nil it is zero value *gqlerror.Error.

The issue had been raised in the past: https://github.com/vektah/gqlparser/issues/99 and they also had a PR for fix https://github.com/vektah/gqlparser/pull/100 which then was closed by author themself.

coveralls commented 2 years ago

Coverage Status

Coverage decreased (-0.02%) to 88.562% when pulling f8402753bf0746cdd7d539ab460d1a658ae733b4 on schafle:gqlerr_to_error into 6d97050e566d7f4597992609765ad5bec79cf001 on vektah:master.