Module: GraphQL::Schema::Member::Scoped
- Included in:
- Interface::DefinitionMethods, GraphQL::Schema::Member
- Defined in:
- lib/graphql/schema/member/scoped.rb
Overview
-- @requires_ancestor: GraphQL::Schema::FindInheritedValue
Instance Method Summary collapse
-
#inherited(subclass) ⇒ Object
: (Module subclass) -> void.
-
#reauthorize_scoped_objects(new_value = nil) ⇒ Object
: (?bool? new_value) -> bool?.
-
#scope_items(items, context) ⇒ Object
This is called when a field has
scope: true.
Instance Method Details
#inherited(subclass) ⇒ Object
: (Module subclass) -> void
46 47 48 49 50 51 |
# File 'lib/graphql/schema/member/scoped.rb', line 46 def inherited(subclass) super subclass.class_exec do @reauthorize_scoped_objects = nil #: bool? end end |
#reauthorize_scoped_objects(new_value = nil) ⇒ Object
: (?bool? new_value) -> bool?
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/graphql/schema/member/scoped.rb', line 33 def (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 #: bool? end end |
#scope_items(items, context) ⇒ Object
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.
Parameters
items(Object) — Some list-like object (eg, Array, ActiveRecord::Relation)context(GraphQL::Query::Context)
Returns
Object— Another list-like object, scoped to the current context
:call-seq:
scope_items(Object items, GraphQL::Query::Context context) -> Object
: (untyped items, GraphQL::Query::Context context) -> untyped
28 29 30 |
# File 'lib/graphql/schema/member/scoped.rb', line 28 def scope_items(items, context) items end |