class GraphQL::Relay::RangeAdd
}
newCommentEdge: range_add.edge,
commentsConnection: range_add.connection,
post: post,
response = {
)
context: ctx,
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: Relay::Edge)
-
edge_class
(Class
) -- The class to wrap `item` with -
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: Relay::Edge) connection_class = BaseConnection.connection_for_nodes(collection) @parent = parent @connection = connection_class.new(collection, {}, parent: parent, context: context) @edge = edge_class.new(item, @connection) end