Skip to main content
RAM usage of subscriptions scales poorly under high load, making the feature unsuitable for most production uses. There are currently no plans to fix this issue.
OpenReader supports GraphQL subscriptions via live queries. To use these, a client opens a websocket connection to the server and sends a subscription query there. The query body is then repeatedly executed (every 5 seconds by default) and the results are sent to the client whenever they change. To enable subscriptions, add the additional --subscriptions flag to the squid-graphql-server startup command. The poll interval is configured with the --subscription-poll-interval flag. For details and a full list of available options, run
For each entity types, the following queries are supported for subscriptions:
  • ${EntityName}ById — query a single entity
  • ${EntityName}s — query multiple entities with a where filter The same list query is available in the regular query set.

Local runs

To enable subscriptions, add the --subscriptions flag to serve and serve:prod commands at commands.json:
commands.json
A ws endpoint will be available the usual localhost:<GQL_PORT>/graphql URL.

SQD Cloud deployments

For SQD Cloud deployments, make sure to use the updated serve:prod command in the deployment manifest:
squid.yaml
The subscription wss endpoint will be available at the canonical API endpoint wss://{org}.subsquid.io/{name}/v/v{version}/graphql.

Example

Let’s take the following simple schema with account and transfer entities:
file=schema.graphql
After modifying commands.json start the GraphQL server with subscriptions with
The following sample script will subscribe to the most recent transfers (by timestamp).