Overview

Note: Equivalent applyUpdate and commitUpdate methods are also
provided on the this.props.relay prop that is passed to components by
Relay.Container. These dispatch mutations in the context of the currently
active Relay.Environment.

The commitUpdate method is analogous to dispatching an action in Flux. Relay processes
the mutation as follows:

If the mutation defines an optimistic payload - a set of data to apply locally while waiting for the server response - Relay applies this change and updates any affected React components (note that optimistic updates do not overwrite known server data in the cache).

If the mutation would not 'collide' (overlap) with other pending mutations - as specified by its getCollisionKey implementation - it is sent to the server. If it would conflict, it is enqueued until conflicting mutations have completed.

When the server response is received, one of the callbacks is invoked: