Subscription Examples
🚨 This feature is currently under development! For more information or to express interest in using this feature, please contact us at
dev@momentum.se
.
Understanding Subscriptions
In GraphQL, the subscription type is used to implement real-time functionality. Clients can subscribe to specific events and receive the associated data as it becomes available.
Examples of Subscriptions
Note: When using subscriptions, only
Id
andentityChangeLocalId
are available.Important: Always include
entityChangeLocalId
in every subscription call. This enables you to resume from the last known point in the event of a disconnection.
Subscribe to Changes in Any Contract
This subscription will notify you of any changes or additions to contracts, providing the contract's Id:
Subscribe to Changes in a Specific Contract
This subscription will notify you if a specific contract, identified by its Id, changes:
subscription testSubscribeOnContractByIdChange
{
contractById (id: "0e628534ef0143d6adfeeb631e3a4e3a") {
id
entityChangeLocalId
}
}
Handle missed data
To manage events that occur while disconnected, we provide queries that return EntityChange
.
For example, if you are running a subscription on the entity Contract
and you disconnect with the last row returned having:
Id
: "a unique guid"
entityChangeLocalId
: 123
You can query for changes made after entityChangeLocalId
: 123, like this:
query GetContractChanges
{
contractChangesSync(lastEntityChangeLocalId: 123) {
nodes {
entityId
localId
}
}
}
After a successful change sync, it's possible to go back subscribing on new changes.