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

Some execution errors get swallowed #132

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
2 participants
@dblock

dblock commented Oct 27, 2017

Spec that reproduces the issue in this PR.

The following response produces errors.any? => false.

{
  "data": {
    "rescueFromActiveRecordRecordInvalid": null
  },
  "errors": [
    {
      "message": "Validation failed: Fee in cents can't be blank.",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "rescueFromActiveRecordRecordInvalid"
      ]
    }
  ]
}

You can try this against https://github.com/dblock/graphql-invoices

require "graphql/client"
require "graphql/client/http"

# Star Wars API example wrapper
module API
  HTTP = GraphQL::Client::HTTP.new("http://localhost:3000/graphql")
  Schema = GraphQL::Client.load_schema(HTTP)
  Client = GraphQL::Client.new(schema: Schema, execute: HTTP)
end

CreateInvoiceQuery = API::Client.parse <<-GRAPHQL
  query {
    rescueFromActiveRecordRecordInvalid {
      id
      fee_in_cents
    }
  }
GRAPHQL

result = API::Client.query(CreateInvoiceQuery)

p result

p "ERRORS: #{result.errors.any?}"

Looks like a bug. The GraphQL spec on errors is pretty clear that there should be errors as long as there's a non-empty errors response, but this one gets filtered out in details.

Is this expected? Looks like clients should not rely on response.errors and check against response.data.errors, in which case what's the point of having it?

@josh

This comment has been minimized.

Show comment
Hide comment
@josh

josh May 2, 2018

Member

You can access all nested errors on response.errors.all. That returns a flattened set.

Member

josh commented May 2, 2018

You can access all nested errors on response.errors.all. That returns a flattened set.

@josh josh closed this May 2, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment