Sha256: 125781ebc8ce9c2fa70bc47b81c2074e745b9d0fc0ab0ade28e1d66f142e4def

Contents?: true

Size: 998 Bytes

Versions: 13

Compression:

Stored size: 998 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 NullQuery
        def after_lazy(value)
          yield(value)
        end
      end

      class NullSchema < GraphQL::Schema
      end

      extend Forwardable

      attr_reader :schema, :query, :warden, :dataloader
      def_delegators GraphQL::EmptyObjects::EMPTY_HASH, :[], :fetch, :dig, :key?

      def initialize
        @query = NullQuery.new
        @dataloader = GraphQL::Dataloader::NullDataloader.new
        @schema = NullSchema
        @warden = Schema::Warden::NullWarden.new(context: self, schema: @schema)
      end

      def interpreter?
        true
      end

      class << self
        extend Forwardable

        def instance
          @instance ||= self.new
        end

        def_delegators :instance, :query, :warden, :schema, :interpreter?, :dataloader, :[], :fetch, :dig, :key?
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
graphql-2.0.32 lib/graphql/query/null_context.rb
graphql-2.0.31 lib/graphql/query/null_context.rb
graphql-2.0.29 lib/graphql/query/null_context.rb
graphql-2.0.28 lib/graphql/query/null_context.rb
graphql-2.1.3 lib/graphql/query/null_context.rb
graphql-2.1.2 lib/graphql/query/null_context.rb
graphql-2.1.1 lib/graphql/query/null_context.rb
graphql-2.1.0 lib/graphql/query/null_context.rb
graphql-2.0.27 lib/graphql/query/null_context.rb
graphql-2.0.26 lib/graphql/query/null_context.rb
graphql-2.0.25 lib/graphql/query/null_context.rb
graphql-2.0.24 lib/graphql/query/null_context.rb
graphql-2.0.23 lib/graphql/query/null_context.rb