machinebox / graphql

Simple low-level GraphQL HTTP client for Go
https://blog.machinebox.io/a-graphql-client-library-for-go-5bffd0455878
Apache License 2.0
933 stars 217 forks source link

Expose details for returned errors #48

Open akupila opened 4 years ago

akupila commented 4 years ago

Exposes the error as graphql.Error and returns error details in case they are present in the error response.

The user should assert the error type:

err := cli.Run(...)
if errs, ok := err.(graphql.Errors); ok {
  // Range over errs
}

// or with go 1.13
var errs graphql.Errors
if errors.As(err, errs) {
  // Range over errs
}

Included:

The format matches the June 2018 spec for errors: https://graphql.github.io/graphql-spec/June2018/#sec-Errors

This PR is very similar to some previous ones:

bcaw commented 4 years ago

Could we get some love on this to get merged? It would be great to have better visibility into errors using this lib.

peterhellberg commented 4 years ago

Is there anything blocking this PR from getting merged? (or #24)