thunder icon indicating copy to clipboard operation
thunder copied to clipboard

Errors handling and GraphQL spec

Open adelcasse opened this issue 7 years ago • 5 comments

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 ;)).

adelcasse avatar Aug 20 '18 17:08 adelcasse

Hi @stephen,

Thanks for the quick answer. I don't have access to samsara-dev/backend (probably private organization/repo ?)

adelcasse avatar Aug 20 '18 17:08 adelcasse

@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 ?

adelcasse avatar Aug 21 '18 13:08 adelcasse

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.

ccbrown avatar Mar 01 '19 23:03 ccbrown

I agree. Without any answer here, we finally switched to another library.

adelcasse avatar Mar 02 '19 10:03 adelcasse

@stephen can you please share your inputs about this one?

sijad avatar Jul 22 '20 19:07 sijad