Class: GraphQLActiveRecordResolvers::Association

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql_activerecord_resolvers/association.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass:, irep_node:, root:) ⇒ Association

Returns a new instance of Association.



5
6
7
8
9
# File 'lib/graphql_activerecord_resolvers/association.rb', line 5

def initialize(klass:, irep_node:, root:)
  @klass = klass
  @irep_node = irep_node
  @root = root
end

Instance Attribute Details

#irep_nodeObject (readonly)

Returns the value of attribute irep_node.



3
4
5
# File 'lib/graphql_activerecord_resolvers/association.rb', line 3

def irep_node
  @irep_node
end

#klassObject (readonly)

Returns the value of attribute klass.



3
4
5
# File 'lib/graphql_activerecord_resolvers/association.rb', line 3

def klass
  @klass
end

#rootObject (readonly)

Returns the value of attribute root.



3
4
5
# File 'lib/graphql_activerecord_resolvers/association.rb', line 3

def root
  @root
end

Instance Method Details

#build_includes_argumentsObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/graphql_activerecord_resolvers/association.rb', line 11

def build_includes_arguments
  if root
    child_associations.map(&:build_includes_arguments)
  elsif child_associations.any?
    {
      irep_node_association_name => child_associations.map(&:build_includes_arguments),
    }
  else
    irep_node_association_name
  end
end