Sha256: 31995f021b036ab13e135a5398fb78a1ace76a88e3b6c5f31c60b14a3ca83b7b

Contents?: true

Size: 784 Bytes

Versions: 43

Compression:

Stored size: 784 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 Forwardable

        def instance
          @instance = self.new
        end

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

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
graphql-1.8.1 lib/graphql/query/null_context.rb
graphql-1.8.0 lib/graphql/query/null_context.rb
graphql-1.8.0.pre11 lib/graphql/query/null_context.rb