Class: GraphqlDevise::MountMethod::OperationSanitizer

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql_devise/mount_method/operation_sanitizer.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(default:, only:, skipped:) ⇒ OperationSanitizer

Returns a new instance of OperationSanitizer.



14
15
16
17
18
# File 'lib/graphql_devise/mount_method/operation_sanitizer.rb', line 14

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

Class Method Details

.call(default:, only:, skipped:) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/graphql_devise/mount_method/operation_sanitizer.rb', line 6

def self.call(default:, only:, skipped:)
  new(
    default: default,
    only:    only,
    skipped: skipped
  ).call
end

Instance Method Details

#callObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/graphql_devise/mount_method/operation_sanitizer.rb', line 20

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