Sha256: 997a784be3891d2b40c578b2f8c550d22ad69ae8d3fa1671fbcfeb1cfb0028f0

Contents?: true

Size: 1.99 KB

Versions: 19

Compression:

Stored size: 1.99 KB

Contents

# frozen_string_literal: true
require "spec_helper"

describe GraphQL::Relay::ConnectionResolve do
  let(:query_string) { <<-GRAPHQL
    query getShips($name: String!){
      rebels {
        ships(nameIncludes: $name) {
          edges {
            node {
              name
            }
          }
          parentClassName
        }
      }
    }
    GRAPHQL
  }

  describe "when an execution error is returned" do
    it "adds an error" do
      result = star_wars_query(query_string, { "name" => "error"})
      assert_equal 1, result["errors"].length
      assert_equal "error from within connection", result["errors"][0]["message"]
    end

    it "adds an error for a lazy error" do
      result = star_wars_query(query_string, { "name" => "lazyError"})
      assert_equal 1, result["errors"].length
      assert_equal "lazy error from within connection", result["errors"][0]["message"]
    end

    it "adds an error for a lazy raised error" do
      result = star_wars_query(query_string, { "name" => "lazyRaisedError"})
      assert_equal 1, result["errors"].length
      assert_equal "lazy raised error from within connection", result["errors"][0]["message"]
    end

    it "adds an error for a raised error" do
      result = star_wars_query(query_string, { "name" => "raisedError"})
      assert_equal 1, result["errors"].length
      assert_equal "error raised from within connection", result["errors"][0]["message"]
    end
  end


  describe "when a lazy object is returned" do
    it "returns the items with the correct parent" do
      result = star_wars_query(query_string, { "name" => "lazyObject"})
      assert_equal 5, result["data"]["rebels"]["ships"]["edges"].length
      assert_equal "StarWars::FactionRecord", result["data"]["rebels"]["ships"]["parentClassName"]
    end
  end

  describe "when nil is returned" do
    it "becomes null" do
      result = star_wars_query(query_string, { "name" => "null" })
      conn = result["data"]["rebels"]["ships"]
      assert_equal nil, conn
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
graphql-1.8.0.pre1 spec/graphql/relay/connection_resolve_spec.rb
graphql-1.7.6 spec/graphql/relay/connection_resolve_spec.rb
graphql-1.7.5 spec/graphql/relay/connection_resolve_spec.rb
graphql-1.7.4 spec/graphql/relay/connection_resolve_spec.rb
graphql-1.7.3 spec/graphql/relay/connection_resolve_spec.rb
graphql-1.7.2 spec/graphql/relay/connection_resolve_spec.rb
graphql-1.7.1 spec/graphql/relay/connection_resolve_spec.rb
graphql-1.7.0 spec/graphql/relay/connection_resolve_spec.rb
graphql-1.6.8 spec/graphql/relay/connection_resolve_spec.rb
graphql-1.6.7 spec/graphql/relay/connection_resolve_spec.rb
graphql-1.6.6 spec/graphql/relay/connection_resolve_spec.rb
graphql-1.6.5 spec/graphql/relay/connection_resolve_spec.rb
graphql-1.6.4 spec/graphql/relay/connection_resolve_spec.rb
graphql-1.5.15 spec/graphql/relay/connection_resolve_spec.rb
graphql-1.6.3 spec/graphql/relay/connection_resolve_spec.rb
graphql-1.6.2 spec/graphql/relay/connection_resolve_spec.rb
graphql-1.6.1 spec/graphql/relay/connection_resolve_spec.rb
graphql-1.6.0 spec/graphql/relay/connection_resolve_spec.rb
graphql-1.5.14 spec/graphql/relay/connection_resolve_spec.rb