Class: GraphqlPreloadQueries::Extensions::Preload

Inherits:
GraphQL::Schema::FieldExtension
  • Object
show all
Defined in:
lib/graphql_preload_queries/extensions/preload.rb

Class Method Summary collapse

Class Method Details

.preload_associations(value, node, type_klass) ⇒ Object

Add all the corresponding preloads to the collection

Parameters:

  • value (ActiveCollection)
  • @node (GqlNode)
  • @type_klass (GqlTypeKlass)

Returns:

  • @data with necessary preloads



14
15
16
17
18
19
# File 'lib/graphql_preload_queries/extensions/preload.rb', line 14

def preload_associations(value, node, type_klass)
  preloads = filter_preloads(node, type_klass.preloads || {})
  log_info = { type_klass: type_klass, preloads: preloads, configured: type_klass.preloads }
  GraphqlPreloadQueries.log("Preloading: #{log_info}")
  apply_preloads(value, preloads)
end