class ConnectionHandler: Handler
The ConnectionHandler implements the special logic to handle storing fields tagged with the @connection directive. These fields are most commonly used with @PaginationFragments. The default HandlerProvider for an environment already includes the ConnectionHandler, so for the most part, this works out-of-the-box.
If you have mutations that want to use updater functions to change the lists of edges for your connections, ConnectionHandler exposes some methods that will make those operations much easier.
static let default = ConnectionHandler()
The default connection handler is available as ConnectionHandler.default.
func getConnection(
_ record: RecordProxy,
key: String,
filters: VariableDataConvertible? = nil
) -> RecordProxy?
Normally, you would use the getLinkedField on a RecordProxy to get the record for a field, but connections are stored under a special key to correctly handle the way their arguments change as you are paging through the results. To access the connection field, you can traverse to its parent record and then use getConnection to get it from the correct key.
record: The parent record that contains the connection fieldkey: The key that you specified in the @connection directive on the fieldfilters: The non-paging arguments (or filters) for the connection. These keys should have been passed as filters in the @connection directive on the field.func createEdge(
_ store: inout RecordSourceProxy,
connection: RecordProxy,
node: RecordProxy,
type edgeType: String
) -> RecordProxy
Sometimes you'll have record for a node that you want to add to a connection, but you won't have an edge record for it. You can use createEdge to create that record, which you'll later be able to insert into the connection.
This may not always create a new record. If the connection already has an edge for the node, that edge will be returned instead.
store: The store that you are adding the edge to. This will be passed in as an argument to your updater function.connection: The record for the connection to add the edge to. Note that this method doesn't update the connection record. Use getConnection to get this record.