Module: GraphQLIncludable::ClassMethods

Defined in:
lib/graphql_includable.rb

Instance Method Summary collapse

Instance Method Details

#delegate(*methods, args) ⇒ Object

hook ActiveSupport’s delegate method to track models and where their delegated methods go



20
21
22
23
24
25
# File 'lib/graphql_includable.rb', line 20

def delegate(*methods, args)
  methods.each do |method|
    delegate_cache[method] = args[:to]
  end
  super(*methods, args) if defined?(super)
end

#delegate_cacheObject



15
16
17
# File 'lib/graphql_includable.rb', line 15

def delegate_cache
  @delegate_cache ||= {}
end

#includes_from_graphql(query_context) ⇒ Object



10
11
12
13
# File 'lib/graphql_includable.rb', line 10

def includes_from_graphql(query_context)
  generated_includes = GraphQLIncludable.generate_includes_from_graphql(query_context, self.model_name.to_s)
  includes(generated_includes)
end