Class: GraphQL::Relay::Edge

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(node, connection) ⇒ Edge



9
10
11
12
# File 'lib/graphql/relay/edge.rb', line 9

def initialize(node, connection)
  @node = node
  @connection = connection
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection



8
9
10
# File 'lib/graphql/relay/edge.rb', line 8

def connection
  @connection
end

#nodeObject (readonly)

Returns the value of attribute node



8
9
10
# File 'lib/graphql/relay/edge.rb', line 8

def node
  @node
end

Instance Method Details

#cursorObject



14
15
16
# File 'lib/graphql/relay/edge.rb', line 14

def cursor
  @cursor ||= connection.cursor_from_node(node)
end

#inspectObject



22
23
24
# File 'lib/graphql/relay/edge.rb', line 22

def inspect
  "#<GraphQL::Relay::Edge (#{parent.inspect} => #{node.inspect})>"
end

#parentObject



18
19
20
# File 'lib/graphql/relay/edge.rb', line 18

def parent
  @parent ||= connection.parent
end