Class: GraphQL::Relay::Edge
- Inherits:
-
ObjectType
- Object
- ObjectType
- GraphQL::Relay::Edge
- Defined in:
- lib/graphql/relay/edge.rb
Overview
Mostly an internal concern.
Wraps an object as a ‘node`, and exposes a connection-specific `cursor`.
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Class Method Summary collapse
Instance Method Summary collapse
- #cursor ⇒ Object
-
#initialize(node, connection) ⇒ Edge
constructor
A new instance of Edge.
Constructor Details
#initialize(node, connection) ⇒ Edge
8 9 10 11 |
# File 'lib/graphql/relay/edge.rb', line 8 def initialize(node, connection) @node = node @connection = connection end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
7 8 9 |
# File 'lib/graphql/relay/edge.rb', line 7 def node @node end |
Class Method Details
.create_type(wrapped_type) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/graphql/relay/edge.rb', line 17 def self.create_type(wrapped_type) GraphQL::ObjectType.define do name("#{wrapped_type.name}Edge") field :node, wrapped_type field :cursor, !types.String end end |
Instance Method Details
#cursor ⇒ Object
13 14 15 |
# File 'lib/graphql/relay/edge.rb', line 13 def cursor @cursor ||= @connection.cursor_from_node(node) end |