-
Notifications
You must be signed in to change notification settings - Fork 529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error "extensions" handling doesn't match spec #925
Comments
Hi @dmarkow good catch. This behaviour exists from before extensions were part of the GraphQL spec. I'm fine aiming to change this in 1.6, with the aim to create some kind of warning in a 1.5.x release. |
Any plans on adding the extensions entry? It seems important to have error codes for the client to use: switch (err.extensions.code) {
case 'UNAUTHENTICATED':
// ... For now we can just add those custom data in the errors map though, but it's just a pity not to be able to do it the standard way. |
I vote for this issue to have more priority to catch-up with GraphQL spec. 👍🏻 I'm just trying to sell Elixir + Absinthe to my friends, and I've found that Absinthe is outdated with this spec 😂 |
I've pushed a PR to fix this. As this is a breaking change, it is opt-in for now. |
@maartenvanvliet how can this be configured when actually using Absinthe? I am looking at pipeline code and seeing that def for_document(schema, options \\ []) do
...
# Format Result
Phase.Document.Result,
...
end file ref: absinthe/lib/absinthe/pipeline.ex Line 120 in 3c102f0
Do we need another PR to make this configurable through |
@thecynicalpaul you could |
That helped, thanks! |
The GraphQL Spec provides information on how errors should be structured, which includes the
message
,locations
, andpath
keys. The spec then states that anything additional should be nested under anextensions
key rather than added at the top level, the reasoning being that future revisions to the spec may add additional keys that could conflict with any custom data.Right now errors seem to be processed in this way:
{:error, message: "bad request", something: "something"}
%Phase.Error{}
struct with all of the keys other thanmessage
being pushed into a nestedextra
field:{:error, message: "bad request", extra: %{something: "something"}}
Absinthe.Phase.Document.Result.format_error/1
later merges theextra
key back into the top level.%{errors: [%{message: "bad request", something: "something"}]
.In the mean time I can get around this by having my resolvers explicitly nest my extra info under an
extensions
key.I'm not sure if this is something that should be changed in Absinthe to match the spec, or if we just need to update the Errors documentation to state that extra info should be in an
extensions
key.Environment
Expected behavior
Based on the spec, I would expect the errors to be returned as:
Actual behavior
The errors are returned as:
The text was updated successfully, but these errors were encountered: