Subscriptions (listen)
For when you want to listen to changes to data on Pitchly

Endpoints

Endpoint
Description
Triggers when rows have changed in a database.
Triggers when a database has been updated.
GraphQL Subscriptions use websockets to capture changes to data as they happen. This is most useful when building apps via Pitchly's App SDK. Since this type of functionality is specific to GraphQL, only the relevant GraphQL queries will be shown here.
If you are looking to get notifications of changes via REST Hooks, Pitchly offers support for hooks as well. As we work on additional documentation, contact us for more information on how to use REST Hooks with Pitchly.

dataRowsChanged

Listens to changes to rows in a database. Use in combination with a data query.
1
subscription dataRowsChanged($secretKey: String!, $databaseId: ID!) {
2
dataRowsChanged(secretKey: $secretKey, databaseId: $databaseId) {
3
_id
4
cols {
5
fieldId
6
value
7
}
8
}
9
}
Copied!

Variables:

1
{
2
"secretKey": <SECRET_KEY>,
3
"databaseId": <DATABASE_ID>
4
}
Copied!
Initiating a subscription does not return data. Instead, it just starts listening for new data as it comes in. In this case, whenever rows change in a database, the new data for each changed row will be received instantly. The data returned by this subscription is identical to the data returned by the data query.
If you're using a GraphQL client, like Apollo, you can use this subscription in combination with the data query to create an always-up-to-date cache of data. See a code example.
dataRowsChanged will only be triggered on rows that have actually changed. Update operations that do not actually result in a change to data will not trigger as a change.

databaseUpdated

Listens to changes to a database, including database fields. Use in combination with a database query.
1
subscription databaseUpdated($secretKey: String!, $id: ID!) {
2
databaseUpdated(secretKey: $secretKey, id: $id) {
3
_id
4
name
5
fields {
6
_id
7
name
8
type
9
primary
10
required
11
restrict
12
database
13
}
14
}
15
}
Copied!

Variables:

1
{
2
"secretKey": <SECRET_KEY>,
3
"id": <DATABASE_ID>
4
}
Copied!
Triggers when a database is updated. This includes changes to information about the database itself or any of its fields. The data returned by this subscription is identical to the data returned by the database query.
See how to use this subscription in combination with the database query using Apollo.
Last modified 1yr ago
Export as PDF
Copy link