Class: GraphQL::Query::NullContext

Inherits:
Context
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/graphql/query/null_context.rb

Overview

This object can be ctx in places where there is no query

Defined Under Namespace

Classes: NullQuery, NullSchema

Constant Summary

Constants inherited from Context

Context::RUNTIME_METADATA_KEYS, Context::UNSPECIFIED_FETCH_DEFAULT

Instance Attribute Summary collapse

Attributes inherited from Context

#errors, #interpreter, #scoped_context, #types, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Context

#[], #[]=, #add_error, #backtrace, #current_path, #delete, #dig, #execution_errors, #fetch, #inspect, #key?, #logger, #namespace, #namespace?, #response_extensions, #scoped, #scoped_merge!, #scoped_set!, #skip, #to_h

Methods included from Schema::Member::HasDataloader

#dataload, #dataload_all, #dataload_association, #dataload_record

Constructor Details

#initialize(schema: NullSchema) ⇒ NullContext

Returns a new instance of NullContext.



29
30
31
32
33
34
35
36
# File 'lib/graphql/query/null_context.rb', line 29

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

Instance Attribute Details

#dataloaderObject (readonly)

Returns the value of attribute dataloader.



26
27
28
# File 'lib/graphql/query/null_context.rb', line 26

def dataloader
  @dataloader
end

#queryObject (readonly)

Returns the value of attribute query.



26
27
28
# File 'lib/graphql/query/null_context.rb', line 26

def query
  @query
end

#schemaObject (readonly)

Returns the value of attribute schema.



26
27
28
# File 'lib/graphql/query/null_context.rb', line 26

def schema
  @schema
end

#wardenObject (readonly)

Returns the value of attribute warden.



26
27
28
# File 'lib/graphql/query/null_context.rb', line 26

def warden
  @warden
end

Class Method Details

.instanceObject



7
8
9
# File 'lib/graphql/query/null_context.rb', line 7

def self.instance
  @instance ||= self.new
end

.instance=(new_inst) ⇒ Object



11
12
13
# File 'lib/graphql/query/null_context.rb', line 11

def self.instance=(new_inst)
  @instance = new_inst
end