Subscriptions
OpenReader supports GraphQL subscriptions via live queries. To use these, a client opens a websocket connection to the server and sends asubscription 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
${EntityName}ById— query a single entity${EntityName}s— query multiple entities with awherefilter
Despite being
deprecated
from the regular query set,
${EntityName}s queries will continue to be
available for subscriptions going forward.Local runs
To enable subscriptions, add the--subscriptions flag to serve and serve:prod commands at commands.json:
commands.json
ws endpoint will be available the usual localhost:<GQL_PORT>/graphql URL.
SQD Cloud deployments
For SQD Cloud deployments, make sure to use the updatedserve:prod command in the deployment manifest:
squid.yaml
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:schema.graphql
commands.json start the GraphQL server with subscriptions with
timestamp).

