Skip to content

Commit 26a791e

Browse files
committed
Add alternative to deprecated asWebSocketHttpRequestHandler
1 parent 4868ab4 commit 26a791e

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

spring-graphql/src/main/java/org/springframework/graphql/server/webmvc/GraphQlWebSocketHandler.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,26 @@ public List<String> getSubProtocols() {
128128
return SUB_PROTOCOL_LIST;
129129
}
130130

131+
/**
132+
* Initialize a {@link WebSocketHttpRequestHandler} that wraps this instance
133+
* and also inserts a {@link HandshakeInterceptor} for context propagation.
134+
* @since 1.1.0
135+
*/
136+
public WebSocketHttpRequestHandler initWebSocketHttpRequestHandler(HandshakeHandler handshakeHandler) {
137+
WebSocketHttpRequestHandler handler = new WebSocketHttpRequestHandler(this, handshakeHandler);
138+
handler.setHandshakeInterceptors(Collections.singletonList(this.contextHandshakeInterceptor));
139+
return handler;
140+
}
141+
131142
/**
132143
* Return a {@link WebSocketHttpRequestHandler} that uses this instance as
133144
* its {@link WebGraphQlHandler} and adds a {@link HandshakeInterceptor} to
134145
* propagate context.
135-
* @deprecated as of 1.1.0 without a replacement, there should be no need for it
146+
* @deprecated as of 1.1.0 in favor of {@link #initWebSocketHttpRequestHandler(HandshakeHandler)}
136147
*/
137148
@Deprecated
138149
public WebSocketHttpRequestHandler asWebSocketHttpRequestHandler(HandshakeHandler handshakeHandler) {
139-
WebSocketHttpRequestHandler handler = new WebSocketHttpRequestHandler(this, handshakeHandler);
140-
handler.setHandshakeInterceptors(Collections.singletonList(this.contextHandshakeInterceptor));
141-
return handler;
150+
return initWebSocketHttpRequestHandler(handshakeHandler);
142151
}
143152

144153

0 commit comments

Comments
 (0)