vektah / gqlparser

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

Add `Is(err error) bool` to gqlerror to work with `errors.Is` #249

Open RobAtticus opened 1 year ago

RobAtticus commented 1 year ago

What happened?

Trying to compare two gqlerrors using either errors.Is or something like https://github.com/google/go-cmp with cmpopts.EquateErrors fails when the two errors have all the same fields, but are different structs.

What did you expect?

The comparison to succeed. Because gqlerror does not implement an Is method, it fails even though they are for all intents and purposes equal.

versions

StevenACoffman commented 1 year ago

Excellent idea! PR welcome!

RobAtticus commented 1 year ago

I'm not sure I have enough context on each of the fields to say what equal should be. Hopefully someone with more confidence can step in.