Skip to content

Commit 7ae8c44

Browse files
committed
Update docs on client side cancellation of subscription
Closes gh-724
1 parent d5d9573 commit 7ae8c44

File tree

1 file changed

+16
-13
lines changed
  • spring-graphql-docs/src/docs/asciidoc/includes

1 file changed

+16
-13
lines changed

spring-graphql-docs/src/docs/asciidoc/includes/client.adoc

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,10 @@ You can use the `GraphQlClient` <<client.graphqlclient.builder>> to customize th
350350
[[client.subscriptions]]
351351
== Subscription Requests
352352

353-
`GraphQlClient` can execute subscriptions over transports that support it. Currently, only
354-
the WebSocket transport supports GraphQL streams, so you'll need to create a
355-
<<client.websocketgraphqlclient,WebSocketGraphQlClient>>.
353+
`GraphQlClient` can execute subscriptions over transports that support it. Only
354+
the WebSocket and RSocket transports support GraphQL subscriptions, so you'll need to
355+
create a <<client.websocketgraphqlclient,WebSocketGraphQlClient>> or
356+
<<client.rsocketgraphqlclient,RSocketGraphQlClient>>.
356357

357358

358359

@@ -370,18 +371,20 @@ responses, each decoded to some data:
370371
.toEntity(String.class);
371372
----
372373

373-
A subscription stream may end with:
374-
375-
- `SubscriptionErrorException` if the server ends the
376-
subscription with an explicit "error" message that contains one or more GraphQL errors.
377-
The exception provides access to the GraphQL errors decoded from that message.
378-
- `GraphQlTransportException` such as `WebSocketDisconnectedException` if the underlying
379-
connection is closed or lost in which case you can use the `retry` operator to reestablish
380-
the connection and start the subscription again.
381-
382-
374+
The `Flux` may terminate with `SubscriptionErrorException` if the subscription ends from
375+
the server side with an "error" message. The exception provides access to GraphQL errors
376+
decoded from the "error" message.
383377

378+
The `Flux` may termiate with `GraphQlTransportException` such as
379+
`WebSocketDisconnectedException` if the underlying connection is closed or lost. In that
380+
case you can use the `retry` operator to restart the subscription.
384381

382+
To end the subscription from the client side, the `Flux` must be cancelled, and in turn
383+
the WebSocket transport sends a "complete" message to the server. How to cancel the
384+
`Flux` depends on how it is used. Some operators such as `take` or `timeout` themselves
385+
cancel the `Flux`. If you subscribe to the `Flux` with a `Subscriber`, you can get a
386+
reference to the `Subscription` and cancel through it. The `onSubscribe` operator also
387+
provides access to the `Subscription`.
385388

386389

387390
[[client.subscriptions.execute]]

0 commit comments

Comments
 (0)