Sha256: a93f76e2c7ed9b466195089187d7790eb9e77b3f553358cabf2592b075cf76ea

Contents?: true

Size: 1.13 KB

Versions: 5

Compression:

Stored size: 1.13 KB

Contents

# typed: strict
# frozen_string_literal: true

module Spoom
  module Deadcode
    module Plugins
      class GraphQL < Base
        extend T::Sig

        ignore_classes_inheriting_from(
          "GraphQL::Schema::Enum",
          "GraphQL::Schema::Object",
          "GraphQL::Schema::Scalar",
          "GraphQL::Schema::Union",
        )

        ignore_methods_named(
          "coerce_input",
          "coerce_result",
          "graphql_name",
          "resolve",
          "resolve_type",
          "subscribed",
          "unsubscribed",
        )

        sig { override.params(send: Send).void }
        def on_send(send)
          return unless send.recv.nil? && send.name == "field"

          arg = send.args.first
          return unless arg.is_a?(Prism::SymbolNode)

          @index.reference_method(arg.unescaped, send.location)

          send.each_arg_assoc do |key, value|
            key = key.slice.delete_suffix(":")
            next unless key == "resolver_method"
            next unless value

            @index.reference_method(value.slice.delete_prefix(":"), send.location)
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spoom-1.5.0 lib/spoom/deadcode/plugins/graphql.rb
spoom-1.4.2 lib/spoom/deadcode/plugins/graphql.rb
spoom-1.4.1 lib/spoom/deadcode/plugins/graphql.rb
spoom-1.4.0 lib/spoom/deadcode/plugins/graphql.rb
spoom-1.3.3 lib/spoom/deadcode/plugins/graphql.rb