Errors handling and GraphQL spec
Hello,
I'm new to this library so please excuse me if I'm out of scope or didn't understand something.
As far as I've understood, GraphQL errors are returned as strings :
- "name.something: error message" when they are path errors (ie. we gave a name to the query and declared them with errors.New in resolvers)
- "error message" : when we use a sanitized error or if we didn't declare a name for the object.
But the GraphQL specification is quite different : http://facebook.github.io/graphql/June2018/#sec-Errors
Errors messages should look like :
{
"message": "Name for character with ID 1002 could not be fetched.",
"locations": [ { "line": 6, "column": 7 } ],
"path": [ "hero", "heroFriends", 1, "name" ]
}
This leads to issues with client libraries expecting the right format.
Tell me if I missed something. If so, I'm sorry.
In case I'm right, is there any interest in fixing that (which would probably be a breaking change for existing users, and Samsara in the first place) ? If so, we could probably contribute to it as we're definitely interested in using this library in our products (everything else is just perfect ;)).
Hi @stephen,
Thanks for the quick answer. I don't have access to samsara-dev/backend (probably private organization/repo ?)
@stephen I've tried something as a proof of concept to avoid breaking changes but still be able to return valid GraphQL errors if needed. What do you thing about that and is there interest in pursuing this implementation ?
This is kind of a big deal imo. I would call spec violations like this a deal-breaker for any API that hopes to see widespread use.
I agree. Without any answer here, we finally switched to another library.
@stephen can you please share your inputs about this one?