Sha256: fd9d85ddfbe5f3ea71430bda2d45ecfc1441db77808866ea91f3aaa7bc10f489

Contents?: true

Size: 753 Bytes

Versions: 44

Compression:

Stored size: 753 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(node, parent, visitor)
          field_defn = visitor.field_definition
          field = "#{visitor.parent_type_definition.graphql_name}.#{field_defn.graphql_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

44 entries across 44 versions & 1 rubygems

Version Path
graphql-1.11.10 lib/graphql/analysis/ast/field_usage.rb
graphql-1.11.9 lib/graphql/analysis/ast/field_usage.rb
graphql-1.12.14 lib/graphql/analysis/ast/field_usage.rb
graphql-1.12.13 lib/graphql/analysis/ast/field_usage.rb
graphql-1.12.12 lib/graphql/analysis/ast/field_usage.rb
graphql-1.12.11 lib/graphql/analysis/ast/field_usage.rb
graphql-1.12.10 lib/graphql/analysis/ast/field_usage.rb
graphql-1.12.9 lib/graphql/analysis/ast/field_usage.rb
graphql-1.12.8 lib/graphql/analysis/ast/field_usage.rb
graphql-1.12.7 lib/graphql/analysis/ast/field_usage.rb
graphql-1.12.6 lib/graphql/analysis/ast/field_usage.rb
graphql-1.12.5 lib/graphql/analysis/ast/field_usage.rb
graphql-1.11.8 lib/graphql/analysis/ast/field_usage.rb
graphql-1.12.4 lib/graphql/analysis/ast/field_usage.rb
graphql-1.12.3 lib/graphql/analysis/ast/field_usage.rb
graphql-1.12.2 lib/graphql/analysis/ast/field_usage.rb
graphql-1.12.1 lib/graphql/analysis/ast/field_usage.rb
graphql-1.12.0 lib/graphql/analysis/ast/field_usage.rb
graphql-1.11.7 lib/graphql/analysis/ast/field_usage.rb
graphql-1.11.6 lib/graphql/analysis/ast/field_usage.rb