Sha256: 4746b34d3b73043da0ae46a865bc40cef1c93d88cd1e31dd076df590c99d092d

Contents?: true

Size: 1.13 KB

Versions: 5

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

module GraphqlDevise
  module MountMethod
    class OperationSanitizer
      def self.call(default:, only:, skipped:)
        new(
          default: default,
          only:    only,
          skipped: skipped
        ).call
      end

      def initialize(default:, only:, skipped:)
        @default = default
        @only    = only
        @skipped = skipped
      end

      def call
        operations = if @only.present?
          @default.slice(*@only)
        elsif @skipped.present?
          @default.except(*@skipped)
        else
          @default
        end

        operations.each do |operation, values|
          next if values[:deprecation_reason].blank?

          ActiveSupport::Deprecation.warn(<<-DEPRECATION.strip_heredoc, caller)
              `#{operation}` is deprecated and will be removed in a future version of this gem.
              #{values[:deprecation_reason]}

              You can supress this message by skipping `#{operation}` on your ResourceLoader or the
              mount_graphql_devise_for method on your routes file.
          DEPRECATION
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
graphql_devise-0.18.2 lib/graphql_devise/mount_method/operation_sanitizer.rb
graphql_devise-0.18.1 lib/graphql_devise/mount_method/operation_sanitizer.rb
graphql_devise-0.18.0 lib/graphql_devise/mount_method/operation_sanitizer.rb
graphql_devise-0.17.1 lib/graphql_devise/mount_method/operation_sanitizer.rb
graphql_devise-0.17.0 lib/graphql_devise/mount_method/operation_sanitizer.rb