Use scopes for better query performance
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
module PublicForApi
|
||||
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
class_methods do
|
||||
def public_for_api
|
||||
all
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ActiveRecord::Base.send(:include, PublicForApi)
|
||||
@@ -50,7 +50,7 @@ module GraphQL
|
||||
when :multiple_association
|
||||
field_type = field_type.first
|
||||
connection(field_name, -> { created_types[field_type].connection_type }, max_page_size: 50, complexity: 1000) do
|
||||
resolve -> (object, arguments, context) { field_type.public_for_api & object.send(field_name) }
|
||||
resolve -> (object, arguments, context) { object.send(field_name).public_for_api }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user