Sha256: 9ac6da277709487dbb75fd9ad9178456b48fdc0cbfbc6a332683e33be3ac1f40

Contents?: true

Size: 953 Bytes

Versions: 53

Compression:

Stored size: 953 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_nil result["data"]
      assert_equal 1, result["errors"].length
    end
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
graphql-1.8.13 spec/graphql/id_type_spec.rb
graphql-1.8.12 spec/graphql/id_type_spec.rb
graphql-1.9.0.pre1 spec/graphql/id_type_spec.rb
graphql-1.8.11 spec/graphql/id_type_spec.rb
graphql-1.8.10 spec/graphql/id_type_spec.rb
graphql-1.8.9 spec/graphql/id_type_spec.rb
graphql-1.8.8 spec/graphql/id_type_spec.rb
graphql-1.8.7 spec/graphql/id_type_spec.rb
graphql-1.8.6 spec/graphql/id_type_spec.rb
graphql-1.8.5 spec/graphql/id_type_spec.rb
graphql-1.8.4 spec/graphql/id_type_spec.rb
graphql-1.8.3 spec/graphql/id_type_spec.rb
graphql-1.8.2 spec/graphql/id_type_spec.rb
graphql-1.8.1 spec/graphql/id_type_spec.rb
graphql-1.8.0 spec/graphql/id_type_spec.rb
graphql-1.8.0.pre11 spec/graphql/id_type_spec.rb
graphql-1.8.0.pre10 spec/graphql/id_type_spec.rb
graphql-1.7.14 spec/graphql/id_type_spec.rb
graphql-1.8.0.pre9 spec/graphql/id_type_spec.rb
graphql-1.8.0.pre8 spec/graphql/id_type_spec.rb