Right now dealing with errors is not very graceful as you need to rely on parsing err.Error(). Exporting the error and adding extensions isn't ideal either but at least it let's you try to treat hasura errors a bit more gracefully and do things like:
func parseGraphqlError(err error) error {
var ghErr graphql.Errors
if errors.As(err, &ghErr) {
code, ok := ghErr[0].Extensions["code"]
if !ok {
return err
}
switch code {
case "access-denied":
...
default:
return err
}
}
return err
}
allowing you to treat errors you may be interested in.
Right now dealing with errors is not very graceful as you need to rely on parsing
err.Error()
. Exporting the error and addingextensions
isn't ideal either but at least it let's you try to treat hasura errors a bit more gracefully and do things like:allowing you to treat errors you may be interested in.