Module: GraphqlRails::Types::HidableByGroup

Included in:
ArgumentType, FieldType
Defined in:
lib/graphql_rails/types/hidable_by_group.rb

Overview

Add visibility option based on groups

Instance Method Summary collapse

Instance Method Details

#initialize(*args, groups: [], hidden_in_groups: [], **kwargs, &block) ⇒ Object



9
10
11
12
13
14
# File 'lib/graphql_rails/types/hidable_by_group.rb', line 9

def initialize(*args, groups: [], hidden_in_groups: [], **kwargs, &block)
  super(*args, **kwargs, &block)

  @hidden_in_groups = hidden_in_groups.map(&:to_s)
  @groups = groups.map(&:to_s) - @hidden_in_groups
end

#visible?(context) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/graphql_rails/types/hidable_by_group.rb', line 16

def visible?(context)
  super && visible_in_context_group?(context)
end