Sha256: 72b50a4f67ad00fdcf225f006405c8c843f92ec291fecf5bb762e9e4b86c0449

Contents?: true

Size: 928 Bytes

Versions: 43

Compression:

Stored size: 928 Bytes

Contents

require "spec_helper"

describe GraphQL::ID_TYPE do
  let(:result) { DummySchema.execute(query_string)}

  describe "coercion for int inputs" do
    let(:query_string) { %|query getMilk { cow: milk(id: 1) { id } }| }

    it "coerces IDs from ints and serializes as strings" do
      expected = {"data" => {"cow" => {"id" => "1"}}}
      assert_equal(expected, result)
    end
  end

  describe "coercion for string inputs" do
    let(:query_string) { %|query getMilk { cow: milk(id: "1") { id } }| }

    it "coerces IDs from strings and serializes as strings" do
      expected = {"data" => {"cow" => {"id" => "1"}}}
      assert_equal(expected, result)
    end
  end

  describe "coercion for other types" do
    let(:query_string) { %|query getMilk { cow: milk(id: 1.0) { id } }| }

    it "doesn't allow other types" do
      assert_equal nil, result["data"]
      assert_equal 1, result["errors"].length
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
graphql-1.2.6 spec/graphql/id_type_spec.rb
graphql-1.2.5 spec/graphql/id_type_spec.rb
graphql-1.2.4 spec/graphql/id_type_spec.rb
graphql-1.2.3 spec/graphql/id_type_spec.rb
graphql-1.2.2 spec/graphql/id_type_spec.rb
graphql-1.2.1 spec/graphql/id_type_spec.rb
graphql-1.2.0 spec/graphql/id_type_spec.rb
graphql-1.1.0 spec/graphql/id_type_spec.rb
graphql-1.0.0 spec/graphql/id_type_spec.rb
graphql-0.19.4 spec/graphql/id_type_spec.rb
graphql-0.19.3 spec/graphql/id_type_spec.rb
graphql-0.19.2 spec/graphql/id_type_spec.rb
graphql-0.19.1 spec/graphql/id_type_spec.rb
graphql-0.19.0 spec/graphql/id_type_spec.rb
graphql-0.18.15 spec/graphql/id_type_spec.rb
graphql-0.18.14 spec/graphql/id_type_spec.rb
graphql-0.18.13 spec/graphql/id_type_spec.rb
graphql-0.18.12 spec/graphql/id_type_spec.rb
graphql-0.18.11 spec/graphql/id_type_spec.rb
graphql-0.18.10 spec/graphql/id_type_spec.rb