module GraphQL::SmartSelect
Apply additional scope to the AR query which selects only the required fields
Constants
- VERSION
Attributes
db_columns[R]
smart_select[R]
Public Class Methods
new(*args, **kwargs, &block)
click to toggle source
Calls superclass method
# File lib/graphql/smart_select.rb, line 14 def initialize(*args, **kwargs, &block) @smart_select = kwargs.delete(:smart_select) @db_columns = kwargs.delete(:db_columns) super end
Private Instance Methods
apply_scope(value, ctx)
click to toggle source
Calls superclass method
# File lib/graphql/smart_select.rb, line 22 def apply_scope(value, ctx) if smart_select && value.is_a?(ActiveRecord::Relation) fields_for_select = Resolver.new(value, ctx, smart_select).resolve value = value.select(fields_for_select) end super end