···3434In the above example, we add the `subscriptionExchange` to the `Client` with the default exchanges
3535added before it. The `subscriptionExchange` is a factory that accepts additional options and returns
3636the actual `Exchange` function. It does not make any assumption over the transport protocol and
3737-scheme that is used. Instead, we need to pass a `forwardSubscription` function, which is called with
3838-an "enriched" _Operation_ every time the `Client` attempts to execute a GraphQL Subscription.
3737+scheme that is used. Instead, we need to pass a `forwardSubscription` function.
3838+3939+The `forwardSubscription` is called when the `subscriptionExchange` receives an `Operation`, so
4040+typically, when you’re executing a GraphQL subscription. This will call the `forwardSubscription`
4141+function with a GraphQL request body, in the same shape that a GraphQL HTTP API may receive it as
4242+JSON input.
4343+4444+If you’re using TypeScript, you may notice that the input that `forwardSubscription` receives has
4545+an optional `query` property. This is because of persisted query support. For some transports, the
4646+`query` property may have to be defaulted to an empty string, which matches the GraphQL over HTTP
4747+specification more closely.
39484049When we define this function it must return an "Observable-like" object, which needs to follow the
4150[Observable spec](https://github.com/tc39/proposal-observable), which comes down to having an
···5968 cacheExchange,
6069 fetchExchange,
6170 subscriptionExchange({
6262- forwardSubscription: request => ({
6363- subscribe: sink => ({
6464- unsubscribe: wsClient.subscribe(request, sink),
6565- }),
6666- }),
7171+ forwardSubscription(request) {
7272+ const input = { ...request, query: request.query || '' };
7373+ return {
7474+ subscribe(sink) {
7575+ const unsubscribe = wsClient.subscribe(input, sink);
7676+ return { unsubscribe };
7777+ },
7878+ };
7979+ },
6780 }),
6881 ],
6982});