Class: GraphQL::Relay::RangeAdd
- Inherits:
 - 
      Object
      
        
- Object
 - GraphQL::Relay::RangeAdd
 
 
- Defined in:
 - lib/graphql/relay/range_add.rb
 
Overview
This provides some isolation from GraphQL::Relay internals.
Given a list of items and a new item, it will provide a connection and an edge.
The connection doesn’t receive outside arguments, so the list of items should be ordered and paginated before providing it here.
Instance Attribute Summary collapse
- 
  
    
      #connection  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute connection.
 - 
  
    
      #edge  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute edge.
 - 
  
    
      #parent  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute parent.
 
Instance Method Summary collapse
- 
  
    
      #initialize(collection:, item:, parent: nil, context: nil, edge_class: nil)  ⇒ RangeAdd 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of RangeAdd.
 
Constructor Details
#initialize(collection:, item:, parent: nil, context: nil, edge_class: nil) ⇒ RangeAdd
Returns a new instance of RangeAdd.
      37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56  | 
    
      # File 'lib/graphql/relay/range_add.rb', line 37 def initialize(collection:, item:, parent: nil, context: nil, edge_class: nil) if context && context.schema.new_connections? conn_class = context.schema.connections.wrapper_for(collection) # The rest will be added by ConnectionExtension @connection = conn_class.new(collection, parent: parent, context: context, edge_class: edge_class) # Check if this connection supports it, to support old versions of GraphQL-Pro @edge = if @connection.respond_to?(:range_add_edge) @connection.range_add_edge(item) else @connection.edge_class.new(item, @connection) end else connection_class = BaseConnection.connection_for_nodes(collection) @connection = connection_class.new(collection, {}, parent: parent, context: context) edge_class ||= Relay::Edge @edge = edge_class.new(item, @connection) end @parent = parent end  | 
  
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
      30 31 32  | 
    
      # File 'lib/graphql/relay/range_add.rb', line 30 def connection @connection end  | 
  
#edge ⇒ Object (readonly)
Returns the value of attribute edge.
      30 31 32  | 
    
      # File 'lib/graphql/relay/range_add.rb', line 30 def edge @edge end  | 
  
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
      30 31 32  | 
    
      # File 'lib/graphql/relay/range_add.rb', line 30 def parent @parent end  |