Update Subscriptions

Subscription to UPDATE events will listen to node properties changes. A new event will be triggered for each mutation that modifies the node top-level properties.

Update events will only be triggered if any of the properties have changed. An update that doesn’t modify the properties will be ignored.

UPDATE event

A subscription to a type can be made with the top-level subscription [type]Updated. The subscription will contain the following fields:

  • event: The event triggering this subscription, in this case it will always be "UPDATE".

  • updated<typename>: The properties of the updated node, after modification. Only top-level properties, without relationships, are available.

  • previousState: The old properties of the node, right before the update event. Only top-level properties are available.

  • timestamp: The timestamp in which the mutation was made. Note that multiple events may come with the same timestamp if triggered by the same query.

Example

Considering the following type definitions:

type Movie {
    title: String
    genre: String
}

A subscription to any Movie updated could look like:

subscription MovieUpdated {
    movieUpdated {
        event
        previousState {
            title
            genre
        }
        updatedMovie {
            title
        }
        timestamp
    }
}