class GraphQL::Relay::RangeAdd
}
new_comment_edge: range_add.edge,
comments_connection: range_add.connection,
post: post,
response = {
)
context: context,
item: new_comment,
collection: comments,
parent: post,
range_add = GraphQL::Relay::RangeAdd.new(
new_comment.save!
new_comment = comments.build(body: args)
comments = post.comments
post = Post.find(args)
@example Adding a comment to list of comments
should be ordered and paginated before providing it here.
The connection doesn’t receive outside arguments, so the list of items
Given a list of items and a new item, it will provide a connection and an edge.
This provides some isolation from ‘GraphQL::Relay` internals.
def initialize(collection:, item:, parent: nil, context: nil, edge_class: nil)
-
edge_class
(Class
) -- The class to wrap `item` with (defaults to the connection's edge class) -
context
(GraphQL::Query::Context
) -- The surrounding `ctx`, will be passed to the connection if provided (this is required for cursor encoders) -
parent
(Object
) -- The owner of `collection`, will be passed to the connection if provided -
item
(Object
) -- The newly-added item (will be wrapped in `edge_class`) -
collection
(Object
) -- The list of items to wrap in a connection
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