Sha256: c494f29038894b824b17f722cc850285a5aa2c5b0f8530294a0a0d5cc4f47f84

Contents?: true

Size: 1.45 KB

Versions: 10

Compression:

Stored size: 1.45 KB

Contents

require 'spec_helper'

describe GraphQL::InputObjectType do
  let(:input_object) { DairyProductInputType }
  it 'has a description' do
    assert(input_object.description)
  end

  it 'has input fields' do
    assert(DairyProductInputType.input_fields["fatContent"])
  end

  describe "when sent into a query" do
    let(:variables) { {} }
    let(:result) { DummySchema.execute(query_string, variables: variables) }

    describe "list inputs" do
      let(:variables) { {"search" => [{"source" => "COW"}]} }
      let(:query_string) {%|
        query getCheeses($search: [DairyProductInput]!){
            sheep: searchDairy(product: [{source: SHEEP, fatContent: 0.1}]) {
              ... cheeseFields
            }
            cow: searchDairy(product: $search) {
              ... cheeseFields
            }
        }

        fragment cheeseFields on Cheese {
          flavor
        }
      |}

      it "converts items to plain values" do
        sheep_value = result["data"]["sheep"]["flavor"]
        cow_value = result["data"]["cow"]["flavor"]
        assert_equal("Manchego", sheep_value)
        assert_equal("Brie", cow_value)
      end
    end

    describe "scalar inputs" do
      let(:query_string) {%|
        {
          cheese(id: 1.4) {
            flavor
          }
        }
      |}

      it "converts them to the correct type" do
        cheese_name = result["data"]["cheese"]["flavor"]
        assert_equal("Brie", cheese_name)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
graphql-0.10.9 spec/graphql/input_object_type_spec.rb
graphql-0.10.8 spec/graphql/input_object_type_spec.rb
graphql-0.10.7 spec/graphql/input_object_type_spec.rb
graphql-0.10.6 spec/graphql/input_object_type_spec.rb
graphql-0.10.5 spec/graphql/input_object_type_spec.rb
graphql-0.10.4 spec/graphql/input_object_type_spec.rb
graphql-0.10.3 spec/graphql/input_object_type_spec.rb
graphql-0.10.2 spec/graphql/input_object_type_spec.rb
graphql-0.10.1 spec/graphql/input_object_type_spec.rb
graphql-0.10.0 spec/graphql/input_object_type_spec.rb