Class: Rails::GraphQL::Request::Subscription
- Inherits:
-
Object
- Object
- Rails::GraphQL::Request::Subscription
- Defined in:
- lib/rails/graphql/request/subscription.rb
Overview
GraphQL Request Subscription
A simple object to store information about a generated subscription TODO: Maybe add a callback for the schema allowing it to prepare the context before saving it into a subscription
Constant Summary collapse
- NULL_SCOPE =
Object.new.freeze
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#broadcastable ⇒ Object
(also: #broadcastable?)
readonly
Returns the value of attribute broadcastable.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#operation_id ⇒ Object
readonly
Returns the value of attribute operation_id.
-
#origin ⇒ Object
readonly
Returns the value of attribute origin.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
-
#sid ⇒ Object
(also: #id)
readonly
Returns the value of attribute sid.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
Instance Method Summary collapse
-
#initialize(request, operation) ⇒ Subscription
constructor
A new instance of Subscription.
- #inspect ⇒ Object
- #marshal_dump ⇒ Object
- #updated! ⇒ Object
Constructor Details
#initialize(request, operation) ⇒ Subscription
Returns a new instance of Subscription.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rails/graphql/request/subscription.rb', line 20 def initialize(request, operation) entrypoint = operation.selection.each_value.first # Memory Fingerprint @schema = request.schema.namespace # 1 Symbol @origin = request.origin # * HEAVY! @operation_id = operation.hash # 1 Integer @args = entrypoint.arguments.to_h # 1 Hash of GQL values @field = entrypoint.field # 1 Pointer @context = request.context.to_h # 1 Hash +/- heavy @broadcastable = operation.broadcastable? # 1 Boolean @created_at = Time.current # 1 Integer updated! # 1 Integer @scope = parse_scope(field.full_scope, request, operation) # 1 Integer after save @sid = request.schema.subscription_id_for(self) # 1 String end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
14 15 16 |
# File 'lib/rails/graphql/request/subscription.rb', line 14 def args @args end |
#broadcastable ⇒ Object (readonly) Also known as: broadcastable?
Returns the value of attribute broadcastable.
14 15 16 |
# File 'lib/rails/graphql/request/subscription.rb', line 14 def broadcastable @broadcastable end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
14 15 16 |
# File 'lib/rails/graphql/request/subscription.rb', line 14 def context @context end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
14 15 16 |
# File 'lib/rails/graphql/request/subscription.rb', line 14 def created_at @created_at end |
#field ⇒ Object (readonly)
Returns the value of attribute field.
14 15 16 |
# File 'lib/rails/graphql/request/subscription.rb', line 14 def field @field end |
#operation_id ⇒ Object (readonly)
Returns the value of attribute operation_id.
14 15 16 |
# File 'lib/rails/graphql/request/subscription.rb', line 14 def operation_id @operation_id end |
#origin ⇒ Object (readonly)
Returns the value of attribute origin.
14 15 16 |
# File 'lib/rails/graphql/request/subscription.rb', line 14 def origin @origin end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
14 15 16 |
# File 'lib/rails/graphql/request/subscription.rb', line 14 def schema @schema end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
14 15 16 |
# File 'lib/rails/graphql/request/subscription.rb', line 14 def scope @scope end |
#sid ⇒ Object (readonly) Also known as: id
Returns the value of attribute sid.
14 15 16 |
# File 'lib/rails/graphql/request/subscription.rb', line 14 def sid @sid end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
14 15 16 |
# File 'lib/rails/graphql/request/subscription.rb', line 14 def updated_at @updated_at end |
Instance Method Details
#inspect ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/rails/graphql/request/subscription.rb', line 45 def inspect (+" #<\#{self.class.name}\n \#{schema}@\#{sid}\n [\#{scope.inspect}, \#{args.hash}]\n \#{field.inspect}\n INFO\nend\n").squish << '>' |
#marshal_dump ⇒ Object
41 42 43 |
# File 'lib/rails/graphql/request/subscription.rb', line 41 def marshal_dump raise ::TypeError, +"Request subscriptions must not be used as payload." end |
#updated! ⇒ Object
37 38 39 |
# File 'lib/rails/graphql/request/subscription.rb', line 37 def updated! @updated_at = Time.current end |