Subscriptions (listen)

For when you want to listen to changes to data on Pitchly

Endpoints

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.

subscription dataRowsChanged($secretKey: String!, $databaseId: ID!) {
  dataRowsChanged(secretKey: $secretKey, databaseId: $databaseId) {
    _id
    cols {
      fieldId
      value
    }
  }
}

Variables:

{
  "secretKey": <SECRET_KEY>,
  "databaseId": <DATABASE_ID>
}

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.

subscription databaseUpdated($secretKey: String!, $id: ID!) {
  databaseUpdated(secretKey: $secretKey, id: $id) {
    _id
    name
    fields {
      _id
      name
      type
      primary
      required
      restrict
      database
    }
  }
}

Variables:

{
  "secretKey": <SECRET_KEY>,
  "id": <DATABASE_ID>
}

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 updated