Sha256: cb3188f652f48a69d8334f148880ab75ecb10a678ef1405b6a6a951c2b5f5929

Contents?: true

Size: 737 Bytes

Versions: 19

Compression:

Stored size: 737 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.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

19 entries across 19 versions & 1 rubygems

Version Path
graphql-1.9.21 lib/graphql/analysis/ast/field_usage.rb
graphql-1.9.20 lib/graphql/analysis/ast/field_usage.rb
graphql-1.9.19 lib/graphql/analysis/ast/field_usage.rb
graphql-1.9.18 lib/graphql/analysis/ast/field_usage.rb
graphql-1.9.17 lib/graphql/analysis/ast/field_usage.rb
graphql-1.9.16 lib/graphql/analysis/ast/field_usage.rb
graphql-1.9.15 lib/graphql/analysis/ast/field_usage.rb
graphql-1.9.14 lib/graphql/analysis/ast/field_usage.rb
graphql-1.10.0.pre1 lib/graphql/analysis/ast/field_usage.rb
graphql-1.9.13 lib/graphql/analysis/ast/field_usage.rb
graphql-1.9.12 lib/graphql/analysis/ast/field_usage.rb
graphql-1.9.11 lib/graphql/analysis/ast/field_usage.rb
graphql-1.9.10 lib/graphql/analysis/ast/field_usage.rb
graphql-1.9.9 lib/graphql/analysis/ast/field_usage.rb
graphql-1.9.8 lib/graphql/analysis/ast/field_usage.rb
graphql-1.9.7 lib/graphql/analysis/ast/field_usage.rb
graphql-1.9.6 lib/graphql/analysis/ast/field_usage.rb
graphql-1.9.5 lib/graphql/analysis/ast/field_usage.rb
graphql-1.9.4 lib/graphql/analysis/ast/field_usage.rb