Sha256: e5c68476d7adaa54bab066dd717d61e0a39772aaf7306627e0a3d917cabe8441

Contents?: true

Size: 1.24 KB

Versions: 28

Compression:

Stored size: 1.24 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_field?(field, ctx); true; end
        def visible_argument?(arg, ctx); true; end
        def visible_type?(type, ctx); true; end
        def visible_enum_value?(ev, ctx); true; end
        def visible_type_membership?(tm, ctx); true; end
      end

      class NullQuery
        def with_error_handling
          yield
        end
      end

      class NullSchema < GraphQL::Schema
      end

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

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

      def [](key); end

      def interpreter?
        true
      end

      class << self
        extend Forwardable

        def [](key); end

        def instance
          @instance ||= self.new
        end

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

Version data entries

28 entries across 28 versions & 2 rubygems

Version Path
graphql-1.13.23 lib/graphql/query/null_context.rb
graphql-1.13.22 lib/graphql/query/null_context.rb
graphql-1.13.21 lib/graphql/query/null_context.rb
graphql-1.13.20 lib/graphql/query/null_context.rb
graphql-1.13.19 lib/graphql/query/null_context.rb
graphql-1.13.18 lib/graphql/query/null_context.rb
graphql-1.13.17 lib/graphql/query/null_context.rb
graphql-1.13.16 lib/graphql/query/null_context.rb
graphql-1.13.15 lib/graphql/query/null_context.rb
graphql-1.13.14 lib/graphql/query/null_context.rb
graphql-1.13.13 lib/graphql/query/null_context.rb
graphql_cody-1.13.0 lib/graphql/query/null_context.rb
graphql-1.13.12 lib/graphql/query/null_context.rb
graphql-1.13.11 lib/graphql/query/null_context.rb
graphql-2.0.2 lib/graphql/query/null_context.rb
graphql-2.0.1 lib/graphql/query/null_context.rb
graphql-1.13.10 lib/graphql/query/null_context.rb
graphql-2.0.0 lib/graphql/query/null_context.rb
graphql-1.13.9 lib/graphql/query/null_context.rb
graphql-1.13.8 lib/graphql/query/null_context.rb