Sha256: 85f7a87e1470e9137049863c6eebc8a3861bb2d2343cdaf9b0735f2bd7b82144

Contents?: true

Size: 790 Bytes

Versions: 25

Compression:

Stored size: 790 Bytes

Contents

# frozen_string_literal: true
module GraphQL
  class Query
    # This object can be `ctx` in places where there is no query
    class NullContext
      class NullWarden < GraphQL::Schema::Warden
        def visible?(t); true; end
        def visible_field?(t); true; end
        def visible_type?(t); true; end
      end

      attr_reader :schema, :query, :warden

      def initialize
        @query = nil
        @schema = GraphQL::Schema.new
        @warden = NullWarden.new(
          GraphQL::Filter.new,
          context: self,
          schema: @schema,
        )
      end

      class << self
        extend GraphQL::Delegate

        def instance
          @instance = self.new
        end

        def_delegators :instance, :query, :schema, :warden
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
graphql-1.7.4 lib/graphql/query/null_context.rb
graphql-1.7.3 lib/graphql/query/null_context.rb
graphql-1.7.2 lib/graphql/query/null_context.rb
graphql-1.7.1 lib/graphql/query/null_context.rb
graphql-1.7.0 lib/graphql/query/null_context.rb