Sha256: 9aa391fc40c92bb903c5e41eaf2e706face3bd22e311f5d48f0d052dd50b7dfe

Contents?: true

Size: 794 Bytes

Versions: 2

Compression:

Stored size: 794 Bytes

Contents

# frozen_string_literal: true
require "spec_helper"

describe GraphQL::Schema::CatchallMiddleware do
  let(:result) { DummySchema.execute(query_string) }
  let(:query_string) {%| query noMilk { error }|}

  before do
    DummySchema.middleware << GraphQL::Schema::CatchallMiddleware
  end

  after do
    DummySchema.middleware.delete(GraphQL::Schema::CatchallMiddleware)
  end

  describe "rescuing errors" do
    let(:errors) { query.context.errors }

    it "turns into error messages" do
      expected = {
        "data" => { "error" => nil },
        "errors"=> [
          {
            "message"=>"Internal error",
            "locations"=>[{"line"=>1, "column"=>17}],
            "path"=>["error"]
          },
        ]
      }
      assert_equal(expected, result)
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
graphql-1.4.0 spec/graphql/schema/catchall_middleware_spec.rb
graphql-1.3.0 spec/graphql/schema/catchall_middleware_spec.rb