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.

Using the default handler

static let default = ConnectionHandler()

The default connection handler is available as ConnectionHandler.default.

Getting the connection record

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.

Parameters

Inserting edges into the connection

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.

Parameters