hasura / go-graphql-client

Package graphql provides a GraphQL client implementation.
MIT License
395 stars 91 forks source link

Better library error returns #135

Closed emilaleksanteri closed 4 months ago

emilaleksanteri commented 4 months ago

Would it be possible to have the hasura methods to return the Errors/Error object used by graphql instead of a go error type?

hgiasac commented 4 months ago

Why don't you use errors.As?

var gqlError graphql.Error
if errors.As(err, &gqlError) {
  log.Println(gqlErrors)
}

var gqlErrors graphql.Errors
if errors.As(err, &gqlErrors) {
  log.Println(gqlErrors)
}
emilaleksanteri commented 4 months ago

Why don't you use errors.As?

var gqlError graphql.Error
if errors.As(err, &gqlError) {
  log.Println(gqlErrors)
}

var gqlErrors graphql.Errors
if errors.As(err, &gqlErrors) {
  log.Println(gqlErrors)
}

ooh i didnt know this is possible (semi new to go), thank you so much, game changing!