QuerySubscription

interface QuerySubscription<Data : Any?, Variables : Any?>


A facility to subscribe to a query to be notified of updates to the query's data when the query is executed.

Realtime updates (May 2026)

Starting with SDK version 17.3.0 (May 2026) query subscriptions gained support for realtime updates. See Get real-time updates from SQL Connect for details about this feature in the entire product.

Prior to SDK version 17.3.0, updates were not realtime, and were not pushed from the server. Instead, the notifications were sent whenever the query was explicitly executed by calling QueryRef.execute.

Realtime updates setup and requirements

In order for the server to send realtime updates, caching must be configured in your connector.yaml file. For example:

connectorId: coolstuff
authMode
: PUBLIC
generate
:
kotlinSdk:
package: com.mycompany.coolstuff
clientCache:
maxAge: 1h

Without this setting the server simply will not send realtime updates.

Then, in the .gql files for your connector that define the operations, you will need to add @refresh directives to the queries for which you want realtime updates. Some very simple queries will automatically gain an implicit @refresh directive; however, even mildly complex queries will need the directive added in order to get realtime updates on clients.

Safe for concurrent use

All methods and properties of QuerySubscription are thread-safe and may be safely called and/or accessed concurrently from multiple threads and/or coroutines.

Not stable for inheritance

The QuerySubscription interface is not stable for inheritance in third-party libraries, as new methods might be added to this interface or contracts of the existing methods can be changed.

Summary

Public functions

operator Boolean
equals(other: Any?)

Compares this object with another object for equality, using the === operator.

Int

Calculates and returns the hash code for this object.

String

Returns a string representation of this object, useful for debugging.

Public properties

Flow<QuerySubscriptionResult<Data, Variables>>

A cold flow that collects the query results as they become available.

QueryRef<Data, Variables>

The query whose results this object subscribes.

Public functions

equals

operator fun equals(other: Any?): Boolean

Compares this object with another object for equality, using the === operator.

The implementation of this method simply uses referential equality. That is, two instances of QuerySubscription compare equal using this method if, and only if, they refer to the same object, as determined by the === operator.

Parameters
other: Any?

The object to compare to this for equality.

Returns
Boolean

other === this

hashCode

fun hashCode(): Int

Calculates and returns the hash code for this object.

Returns
Int

the hash code for this object.

toString

fun toString(): String

Returns a string representation of this object, useful for debugging.

The string representation is not guaranteed to be stable and may change without notice at any time. Therefore, the only recommended usage of the returned string is debugging and/or logging. Namely, parsing the returned string or storing the returned string in non-volatile storage should generally be avoided in order to be robust in case that the string representation changes.

Returns
String

a string representation of this object, which includes the class name and the values of all public properties.

Public properties

flow

val flowFlow<QuerySubscriptionResult<Data, Variables>>

A cold flow that collects the query results as they become available.

Starting with SDK version 17.3.0 (May 2026) query subscriptions gained support for realtime updates. See QuerySubscription for details.

query

val queryQueryRef<Data, Variables>

The query whose results this object subscribes.