1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
# frozen_string_literal: true
module GraphQL
class Schema
class Member
module Scoped
# This is called when a field has `scope: true`.
# The field's return type class receives this call.
#
# By default, it's a no-op. Override it to scope your objects.
#
# @param items [Object] Some list-like object (eg, Array, ActiveRecord::Relation)
# @param context [GraphQL::Query::Context]
# @return [Object] Another list-like object, scoped to the current context
def scope_items(items, context)
items
end
def reauthorize_scoped_objects(new_value = nil)
if new_value.nil?
if @reauthorize_scoped_objects != nil
@reauthorize_scoped_objects
else
find_inherited_value(:reauthorize_scoped_objects, true)
end
else
@reauthorize_scoped_objects = new_value
end
end
def inherited(subclass)
super
subclass.class_exec do
@reauthorize_scoped_objects = nil
end
end
end
end
end
end
|