Sha256: da26031549f21444c1abd6fcdc0f3efcc88ac80d54ba3d16f0d1cbabf36101ce

Contents?: true

Size: 738 Bytes

Versions: 8

Compression:

Stored size: 738 Bytes

Contents

# frozen_string_literal: true
module GraphQL
  module Analysis
    module AST
      class FieldUsage < Analyzer
        def initialize(query)
          super
          @used_fields = Set.new
          @used_deprecated_fields = Set.new
        end

        def on_leave_field(parent,  node, visitor)
          field_defn = visitor.field_definition
          field = "#{visitor.parent_type_definition.name}.#{field_defn.name}"
          @used_fields << field
          @used_deprecated_fields << field if field_defn.deprecation_reason
        end

        def result
          {
            used_fields: @used_fields.to_a,
            used_deprecated_fields: @used_deprecated_fields.to_a
          }
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
graphql-1.9.3 lib/graphql/analysis/ast/field_usage.rb
graphql-1.9.2 lib/graphql/analysis/ast/field_usage.rb
graphql-1.9.1 lib/graphql/analysis/ast/field_usage.rb
graphql-1.9.0 lib/graphql/analysis/ast/field_usage.rb
graphql-1.9.0.pre4 lib/graphql/analysis/ast/field_usage.rb
graphql-1.9.0.pre3 lib/graphql/analysis/ast/field_usage.rb
graphql-1.9.0.pre2 lib/graphql/analysis/ast/field_usage.rb
graphql-1.9.0.pre1 lib/graphql/analysis/ast/field_usage.rb