Skip to main content
Version: v3.x (DDN)

Basics of Subscriptions

Introduction

Subscriptions allow you to push real-time updates from your data sources to clients, making them ideal for building reactive applications without constant polling.

Currently in beta

Subscriptions are in beta and are free to use during this period.

Configuration

You can enable subscriptions on your GraphQL API in the following ways:

New Hasura DDN project

If you're starting fresh, set up a Hasura DDN project using the quickstart guide. After adding your models to the supergraph using the ddn model add command, subscription capabilities are automatically generated! For further customization, you can edit the metadata.

Existing Hasura DDN project

To enable subscriptions in an existing DDN project, use the following CLI command:

ddn codemod upgrade-graphqlconfig-subscriptions

This command updates the local metadata files, adding subscription-specific configurations. After running this, create a supergraph build and test the subscriptions on the API. For further customization, you can edit the metadata.

Metadata configuration

You can configure the overall usage of subscriptions in your GraphQL API using the GraphQlConfig object in your metadata.

Additionally, you can customize individual subscriptions by modifying the SubscriptionGraphQlDefinition field on any model's selectUniques, selectMany, or aggregate fields.

Learn more

Subscriptions are supported for the following queries: