You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add Apollo Subscription Lifecycle Events (WIP):
* switch lifecycle events to monos
* adjust tests
* update tests and add state variable for onConnect
* add MySubscriptionHooks bean
* fix lint issues
* Update SubscriptionAutoConfiguration.kt
Change apolloLifeCycleEvents to apolloSubscriptionHooks
* add documentation and tests
* reorder test
* get rid of extra assertion in test
* alter tests to reflect that flux won't play twice
* fix lint
* fix lint
* default to using empty params in onConnect rather than empty mono
* switch some tests to using StepVerifier
Copy file name to clipboardExpand all lines: docs/spring-server/subscriptions.md
+13-1Lines changed: 13 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -7,15 +7,27 @@ title: Subscriptions
7
7
To see more details of how to implement subscriptions in your schema, see [executing subscriptions](../execution/subscriptions).
8
8
9
9
## `graphql-ws` subprotocol
10
+
###Overview
10
11
We have implemented subscriptions in Spring WebSockets following the [`graphql-ws` subprotocol](https://github.com/apollographql/subscriptions-transport-ws/blob/master/PROTOCOL.md) defined by Apollo. This requires that your client send and parse messages in a specific format.
11
12
12
13
You can see more details in the file [ApolloSubscriptionProtocolHandler](https://github.com/ExpediaGroup/graphql-kotlin/blob/master/graphql-kotlin-spring-server/src/main/kotlin/com/expediagroup/graphql/spring/execution/ApolloSubscriptionProtocolHandler.kt).
13
14
14
15
If you would like to implement your own subscription handler, you can provide a primary spring bean for `HandlerMapping` that overrides the [default one](https://github.com/ExpediaGroup/graphql-kotlin/blob/master/graphql-kotlin-spring-server/src/main/kotlin/com/expediagroup/graphql/spring/SubscriptionAutoConfiguration.kt) which sets the url for subscriptions to the Apollo subscription handler.
15
16
17
+
### Subscription Hooks
18
+
In line with the protocol, we have implemented hooks to execute functions at different stages of the connection lifecycle:
19
+
- onConnect
20
+
- onOperation
21
+
- onOperationComplete
22
+
- onDisconnect
23
+
24
+
You can see more details in the file [ApolloSubscriptionHooks](https://github.com/ExpediaGroup/graphql-kotlin/blob/master/graphql-kotlin-spring-server/src/main/kotlin/com/expediagroup/graphql/spring/execution/ApolloSubscriptionHooks.kt).
25
+
26
+
If you would like to implement your own subscription hooks, you can provide a primary spring bean for `ApolloSubscriptionHooks` that overrides the [default one](https://github.com/ExpediaGroup/graphql-kotlin/blob/master/graphql-kotlin-spring-server/src/main/kotlin/com/expediagroup/graphql/spring/SubscriptionAutoConfiguration.kt) which do not perform any actions.
27
+
28
+
16
29
## Example
17
30
You can see an example implementation of a `Subscription` in the [example app](https://github.com/ExpediaGroup/graphql-kotlin/blob/master/examples/spring/src/main/kotlin/com/expediagroup/graphql/sample/subscriptions/SimpleSubscription.kt).
Copy file name to clipboardExpand all lines: graphql-kotlin-spring-server/src/main/kotlin/com/expediagroup/graphql/spring/SubscriptionAutoConfiguration.kt
Copy file name to clipboardExpand all lines: graphql-kotlin-spring-server/src/main/kotlin/com/expediagroup/graphql/spring/execution/ApolloSubscriptionProtocolHandler.kt
0 commit comments