Sha256: 5e337c0fd030968c7ce651caed8bdebe9f186d448a4aa2d4cd37ef7c68cb7366

Contents?: true

Size: 1.06 KB

Versions: 16

Compression:

Stored size: 1.06 KB

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

      class NullQuery
        def with_error_handling
          yield
        end
      end

      attr_reader :schema, :query, :warden, :dataloader

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

      def [](key); end

      def interpreter?
        false
      end

      class << self
        extend Forwardable

        def [](key); end

        def instance
          @instance = self.new
        end

        def_delegators :instance, :query, :schema, :warden, :interpreter?, :dataloader
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
graphql-1.12.25 lib/graphql/query/null_context.rb
graphql-1.12.24 lib/graphql/query/null_context.rb
graphql-1.12.23 lib/graphql/query/null_context.rb
graphql-1.12.22 lib/graphql/query/null_context.rb
graphql-1.12.21 lib/graphql/query/null_context.rb
graphql-1.12.20 lib/graphql/query/null_context.rb
graphql-1.12.19 lib/graphql/query/null_context.rb
graphql-1.12.18 lib/graphql/query/null_context.rb
graphql-1.12.17 lib/graphql/query/null_context.rb
graphql-1.12.16 lib/graphql/query/null_context.rb
graphql-1.12.15 lib/graphql/query/null_context.rb
graphql-1.12.14 lib/graphql/query/null_context.rb
graphql-1.12.13 lib/graphql/query/null_context.rb
graphql-1.12.12 lib/graphql/query/null_context.rb
graphql-1.12.11 lib/graphql/query/null_context.rb
graphql-1.12.10 lib/graphql/query/null_context.rb