Sha256: 47fa5915aa5cd95df0a5ff06596f13a218f09b6e47e926c39113a109a32dfb47

Contents?: true

Size: 1.57 KB

Versions: 28

Compression:

Stored size: 1.57 KB

Contents

require "spec_helper"

describe GraphQL::ExecutionError do
  let(:result) { DummySchema.execute(query_string) }
  describe "when returned from a field" do
    let(:query_string) {%|
    {
      cheese(id: 1) {
        id
        error1: similarCheese(source: [YAK]) {
          ... similarCheeseFields
        }
        error2: similarCheese(source: [YAK]) {
          ... similarCheeseFields
        }
        nonError: similarCheese(source: [SHEEP]) {
          ... similarCheeseFields
        }
        flavor
      }
      executionError
    }

    fragment similarCheeseFields on Cheese {
      id, flavor
    }
    |}
    it "the error is inserted into the errors key and the rest of the query is fulfilled" do
      expected_result = {
        "data"=>{
          "cheese"=>{
            "id" => 1,
            "error1"=> nil,
            "error2"=> nil,
            "nonError"=> {
              "id" => 3,
              "flavor" => "Manchego",
            },
            "flavor" => "Brie",
            },
            "executionError" => nil,
          },
          "errors"=>[
            {
              "message"=>"No cheeses are made from Yak milk!",
              "locations"=>[{"line"=>5, "column"=>9}]
            },
            {
              "message"=>"No cheeses are made from Yak milk!",
              "locations"=>[{"line"=>8, "column"=>9}]
            },
            {
              "message"=>"There was an execution error",
              "locations"=>[{"line"=>16, "column"=>7}]
            },
          ]
        }
      assert_equal(expected_result, result)
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
graphql-0.18.14 spec/graphql/execution_error_spec.rb
graphql-0.18.13 spec/graphql/execution_error_spec.rb
graphql-0.18.12 spec/graphql/execution_error_spec.rb
graphql-0.18.11 spec/graphql/execution_error_spec.rb
graphql-0.18.10 spec/graphql/execution_error_spec.rb
graphql-0.18.9 spec/graphql/execution_error_spec.rb
graphql-0.18.8 spec/graphql/execution_error_spec.rb
graphql-0.18.7 spec/graphql/execution_error_spec.rb
graphql-0.18.6 spec/graphql/execution_error_spec.rb
graphql-0.18.5 spec/graphql/execution_error_spec.rb
graphql-0.18.4 spec/graphql/execution_error_spec.rb
graphql-0.18.3 spec/graphql/execution_error_spec.rb
graphql-0.18.2 spec/graphql/execution_error_spec.rb
graphql-0.18.1 spec/graphql/execution_error_spec.rb
graphql-0.18.0 spec/graphql/execution_error_spec.rb
graphql-0.17.2 spec/graphql/execution_error_spec.rb
graphql-0.17.1 spec/graphql/execution_error_spec.rb
graphql-0.17.0 spec/graphql/execution_error_spec.rb
graphql-0.16.1 spec/graphql/execution_error_spec.rb
graphql-0.16.0 spec/graphql/execution_error_spec.rb