Sha256: fe8cc2119572acef654ad221290286fa83ca8cc58cefbd2de3ea85d9b092bf1a

Contents?: true

Size: 1.02 KB

Versions: 24

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true
require "spec_helper"

describe GraphQL::Introspection::TypeByNameField do
  describe "after instrumentation" do
    # Just make sure it returns a new object, not the original field
    class DupInstrumenter
      def self.instrument(t, f)
        f.redefine {
          resolve ->(o, a, c) { :no_op }
        }
      end
    end

    class ArgAnalyzer
      def call(_, _, node)
        if node.ast_node.is_a?(GraphQL::Language::Nodes::Field)
          node.arguments
        end
      end
    end

    let(:instrumented_schema) {
      # This was probably assigned earlier in the test suite, but to simulate an application, clear it.
      GraphQL::Introspection::TypeByNameField.arguments_class = nil

      Dummy::Schema.redefine {
        instrument(:field, DupInstrumenter)
        query_analyzer(ArgAnalyzer.new)
      }
    }

    it "still works with __type" do
      res = instrumented_schema.execute("{ __type(name: \"X\") { name } }")
      assert_equal({"data"=>{"__type"=>nil}}, res)
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
graphql-1.8.0 spec/graphql/introspection/type_by_name_field_spec.rb
graphql-1.8.0.pre11 spec/graphql/introspection/type_by_name_field_spec.rb
graphql-1.8.0.pre10 spec/graphql/introspection/type_by_name_field_spec.rb
graphql-1.7.14 spec/graphql/introspection/type_by_name_field_spec.rb
graphql-1.8.0.pre9 spec/graphql/introspection/type_by_name_field_spec.rb
graphql-1.8.0.pre8 spec/graphql/introspection/type_by_name_field_spec.rb
graphql-1.7.13 spec/graphql/introspection/type_by_name_field_spec.rb
graphql-1.8.0.pre7 spec/graphql/introspection/type_by_name_field_spec.rb
graphql-1.7.12 spec/graphql/introspection/type_by_name_field_spec.rb
graphql-1.7.11 spec/graphql/introspection/type_by_name_field_spec.rb
graphql-1.7.10 spec/graphql/introspection/type_by_name_field_spec.rb
graphql-1.8.0.pre6 spec/graphql/introspection/type_by_name_field_spec.rb
graphql-1.8.0.pre5 spec/graphql/introspection/type_by_name_field_spec.rb
graphql-1.7.9 spec/graphql/introspection/type_by_name_field_spec.rb
graphql-1.8.0.pre4 spec/graphql/introspection/type_by_name_field_spec.rb
graphql-1.8.0.pre3 spec/graphql/introspection/type_by_name_field_spec.rb
graphql-1.7.8 spec/graphql/introspection/type_by_name_field_spec.rb
graphql-1.8.0.pre2 spec/graphql/introspection/type_by_name_field_spec.rb
graphql-1.7.7 spec/graphql/introspection/type_by_name_field_spec.rb
graphql-1.8.0.pre1 spec/graphql/introspection/type_by_name_field_spec.rb