Sha256: ed861483353ccf8bccfc690e33498a678dce753c1c983ae3e7977a2d1de0fa04

Contents?: true

Size: 920 Bytes

Versions: 23

Compression:

Stored size: 920 Bytes

Contents

require 'spec_helper'

class TypeCheckValidator
  def self.checks
    @checks ||= []
  end

  def validate(context)
    self.class.checks.clear
    context.visitor[GraphQL::Language::Nodes::Field] << -> (node, parent) {
      self.class.checks << context.object_types.map(&:name)
    }
  end
end

describe GraphQL::StaticValidation::TypeStack do
  let(:query_string) {%|
    query getCheese {
      cheese(id: 1) { id, ... edibleFields }
    }
    fragment edibleFields on Edible { fatContent @skip(if: false)}
  |}
  let(:document) { GraphQL.parse(query_string) }
  let(:validator) { GraphQL::StaticValidation::Validator.new(schema: DummySchema, rules: [TypeCheckValidator]) }

  it 'stores up types' do
    validator.validate(document)
    expected = [
      ["Query", "Cheese"],
      ["Query", "Cheese", "Non-Null"],
      ["Edible", "Non-Null"]
    ]
    assert_equal(expected, TypeCheckValidator.checks)
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
graphql-0.11.1 spec/graphql/static_validation/type_stack_spec.rb
graphql-0.11.0 spec/graphql/static_validation/type_stack_spec.rb
graphql-0.10.9 spec/graphql/static_validation/type_stack_spec.rb
graphql-0.10.8 spec/graphql/static_validation/type_stack_spec.rb
graphql-0.10.7 spec/graphql/static_validation/type_stack_spec.rb
graphql-0.10.6 spec/graphql/static_validation/type_stack_spec.rb
graphql-0.10.5 spec/graphql/static_validation/type_stack_spec.rb
graphql-0.10.4 spec/graphql/static_validation/type_stack_spec.rb
graphql-0.10.3 spec/graphql/static_validation/type_stack_spec.rb
graphql-0.10.2 spec/graphql/static_validation/type_stack_spec.rb
graphql-0.10.1 spec/graphql/static_validation/type_stack_spec.rb
graphql-0.10.0 spec/graphql/static_validation/type_stack_spec.rb
graphql-0.9.5 spec/graphql/static_validation/type_stack_spec.rb
graphql-0.9.4 spec/graphql/static_validation/type_stack_spec.rb
graphql-0.9.3 spec/graphql/static_validation/type_stack_spec.rb
graphql-0.9.2 spec/graphql/static_validation/type_stack_spec.rb
graphql-0.8.1 spec/graphql/static_validation/type_stack_spec.rb
graphql-0.8.0 spec/graphql/static_validation/type_stack_spec.rb
graphql-0.7.1 spec/graphql/static_validation/type_stack_spec.rb
graphql-0.7.0 spec/graphql/static_validation/type_stack_spec.rb