Sha256: e8b2209a01cfe57a5d00df7b4b487b13f0bdc25caccb38496e288576991e38f7

Contents?: true

Size: 1.98 KB

Versions: 37

Compression:

Stored size: 1.98 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_nil conn
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
graphql-1.8.18 spec/integration/rails/graphql/relay/connection_resolve_spec.rb
graphql-1.8.17 spec/integration/rails/graphql/relay/connection_resolve_spec.rb
graphql-1.8.16 spec/integration/rails/graphql/relay/connection_resolve_spec.rb
graphql-1.8.15 spec/integration/rails/graphql/relay/connection_resolve_spec.rb
graphql-1.8.14 spec/integration/rails/graphql/relay/connection_resolve_spec.rb
graphql-1.8.13 spec/integration/rails/graphql/relay/connection_resolve_spec.rb
graphql-1.8.12 spec/integration/rails/graphql/relay/connection_resolve_spec.rb
graphql-1.8.11 spec/integration/rails/graphql/relay/connection_resolve_spec.rb
graphql-1.8.10 spec/integration/rails/graphql/relay/connection_resolve_spec.rb
graphql-1.8.9 spec/integration/rails/graphql/relay/connection_resolve_spec.rb
graphql-1.8.8 spec/integration/rails/graphql/relay/connection_resolve_spec.rb
graphql-1.8.7 spec/graphql/relay/connection_resolve_spec.rb
graphql-1.8.6 spec/graphql/relay/connection_resolve_spec.rb
graphql-1.8.5 spec/graphql/relay/connection_resolve_spec.rb
graphql-1.8.4 spec/graphql/relay/connection_resolve_spec.rb
graphql-1.8.3 spec/graphql/relay/connection_resolve_spec.rb
graphql-1.8.2 spec/graphql/relay/connection_resolve_spec.rb
graphql-1.8.1 spec/graphql/relay/connection_resolve_spec.rb
graphql-1.8.0 spec/graphql/relay/connection_resolve_spec.rb
graphql-1.8.0.pre11 spec/graphql/relay/connection_resolve_spec.rb