Hi,
How should an Absinthe.Resolution struct look like when I want to return both data and errors from Absinthe?
This is now allowed by the GraphQL spec., but whenever I put something into the errors
field of the Absinthe.Resolution struct, the data part of the response disappears from the response. This is what I try to do in a middleware without much success:
def call(resolution, params) do
resolution
|> Absinthe.Resolution.put_result({:error, params.errors})
|> Absinthe.Resolution.put_result({:ok, params.data})
end
…and in the handler function I simply return {:middleware, MyMiddleware, %{data: ..., errors: ...}}
. It doesn’t make any difference when I try to manipulate the resolution
struct directly, not via put_result/2
.
What’s wrong with this approach?
Is it even possible to return data and errors in a single response using Absinthe?