Sha256: b69c65a3fabdd2d0a92334503def98303519cfefe5a8659b2f6ec0eefdd7adf5

Contents?: true

Size: 960 Bytes

Versions: 36

Compression:

Stored size: 960 Bytes

Contents

# frozen_string_literal: true
require "spec_helper"

describe GraphQL::ID_TYPE do
  let(:result) { Dummy::Schema.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

36 entries across 36 versions & 1 rubygems

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