Skip to content

Commit 5ea81a8

Browse files
committed
fix subscriptions by not removing the ak subscription when one of the subscriptions is stopped.
1 parent b387839 commit 5ea81a8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

graphql-kotlin-spring-server/src/main/kotlin/com/expediagroup/graphql/spring/execution/ApolloSubscriptionProtocolHandler.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ class ApolloSubscriptionProtocolHandler(
7575
}
7676
operationMessage.type == GQL_START.type -> startSubscription(operationMessage, session)
7777
operationMessage.type == GQL_STOP.type -> {
78-
stopSubscription(operationMessage, session)
78+
stopSubscription(operationMessage, session, false)
7979
Flux.empty()
8080
}
8181
operationMessage.type == GQL_CONNECTION_TERMINATE.type -> {
82-
stopSubscription(operationMessage, session)
82+
stopSubscription(operationMessage, session, true)
8383
session.close()
8484
Flux.empty()
8585
}
@@ -131,9 +131,11 @@ class ApolloSubscriptionProtocolHandler(
131131
}
132132
}
133133

134-
private fun stopSubscription(operationMessage: SubscriptionOperationMessage, session: WebSocketSession) {
134+
private fun stopSubscription(operationMessage: SubscriptionOperationMessage, session: WebSocketSession, terminate: Boolean) {
135135
if (operationMessage.id != null) {
136-
keepAliveSubscriptions[session.id]?.cancel()
136+
if (terminate) {
137+
keepAliveSubscriptions[session.id]?.cancel()
138+
}
137139
subscriptions[operationMessage.id]?.cancel()
138140
}
139141
}

0 commit comments

Comments
 (0)