Sha256: d0cbf1016ec7bb0cff5c5b6838523379bc4c21eabe1e4413364f2257a05e8a43

Contents?: true

Size: 717 Bytes

Versions: 11

Compression:

Stored size: 717 Bytes

Contents

require 'spec_helper'

describe GraphQL::ID_TYPE do
  let(:query) { GraphQL::Query.new(DummySchema, query_string)}
  let(:result) { query.result }

  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
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
graphql-0.9.2 spec/graphql/id_type_spec.rb
graphql-0.8.1 spec/graphql/id_type_spec.rb
graphql-0.8.0 spec/graphql/id_type_spec.rb
graphql-0.7.1 spec/graphql/id_type_spec.rb
graphql-0.7.0 spec/graphql/id_type_spec.rb
graphql-0.6.2 spec/graphql/id_type_spec.rb
graphql-0.6.1 spec/graphql/id_type_spec.rb
graphql-0.6.0 spec/graphql/id_type_spec.rb
graphql-0.5.0 spec/graph_ql/id_type_spec.rb
graphql-0.4.0 spec/graph_ql/id_type_spec.rb
graphql-0.3.0 spec/graph_ql/scalars/id_type_spec.rb