Sha256: 74c1590181d92edc0d2a0636cc7ec50a533e93a46a52571e16897935de0f104f

Contents?: true

Size: 1.13 KB

Versions: 51

Compression:

Stored size: 1.13 KB

Contents

# 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_eval do
            @reauthorize_scoped_objects = nil
          end
        end
      end
    end
  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
graphql-2.4.8 lib/graphql/schema/member/scoped.rb
graphql-2.4.7 lib/graphql/schema/member/scoped.rb
graphql-2.4.6 lib/graphql/schema/member/scoped.rb
graphql-2.4.5 lib/graphql/schema/member/scoped.rb
graphql-2.4.4 lib/graphql/schema/member/scoped.rb
graphql-2.4.3 lib/graphql/schema/member/scoped.rb
graphql-2.4.2 lib/graphql/schema/member/scoped.rb
graphql-2.4.1 lib/graphql/schema/member/scoped.rb
graphql-2.4.0 lib/graphql/schema/member/scoped.rb
graphql-2.3.20 lib/graphql/schema/member/scoped.rb
graphql-2.3.19 lib/graphql/schema/member/scoped.rb
graphql-2.3.18 lib/graphql/schema/member/scoped.rb
graphql-2.3.17 lib/graphql/schema/member/scoped.rb
graphql-2.3.16 lib/graphql/schema/member/scoped.rb
graphql-2.3.15 lib/graphql/schema/member/scoped.rb
graphql-2.3.14 lib/graphql/schema/member/scoped.rb
graphql-2.3.13 lib/graphql/schema/member/scoped.rb
graphql-2.3.12 lib/graphql/schema/member/scoped.rb
graphql-2.3.11 lib/graphql/schema/member/scoped.rb
graphql-2.3.10 lib/graphql/schema/member/scoped.rb