Class: Gitlab::Graphql::Authorize::ConnectionFilterExtension

Inherits:
GraphQL::Schema::FieldExtension
  • Object
show all
Defined in:
lib/gitlab/graphql/authorize/connection_filter_extension.rb

Defined Under Namespace

Classes: Redactor

Instance Method Summary collapse

Instance Method Details

#after_resolve(value:, context:, **rest) ⇒ Object


48
49
50
51
52
53
54
55
56
57
58
# File 'lib/gitlab/graphql/authorize/connection_filter_extension.rb', line 48

def after_resolve(value:, context:, **rest)
  return value if value.is_a?(GraphQL::Execution::Execute::Skip)

  if @field.connection?
    redact_connection(value, context)
  elsif @field.type.list?
    redact_list(value.to_a, context) unless value.nil?
  end

  value
end

#redact_connection(conn, context) ⇒ Object


60
61
62
63
64
65
# File 'lib/gitlab/graphql/authorize/connection_filter_extension.rb', line 60

def redact_connection(conn, context)
  redactor = Redactor.new(@field.type.unwrap.node_type, context, @field.resolver)
  return unless redactor.active?

  conn.redactor = redactor if conn.respond_to?(:redactor=)
end

#redact_list(list, context) ⇒ Object


67
68
69
70
# File 'lib/gitlab/graphql/authorize/connection_filter_extension.rb', line 67

def redact_list(list, context)
  redactor = Redactor.new(@field.type.unwrap, context, @field.resolver)
  redactor.redact(list) if redactor.active?
end