1
1
package graphql .servlet .internal ;
2
2
3
+ import graphql .servlet .GraphQLSingleInvocationInput ;
4
+
3
5
import javax .websocket .Session ;
4
6
import javax .websocket .server .HandshakeRequest ;
5
7
import java .io .IOException ;
@@ -20,18 +22,23 @@ public FallbackSubscriptionProtocolHandler(SubscriptionHandlerInput subscription
20
22
21
23
@ Override
22
24
public void onMessage (HandshakeRequest request , Session session , WsSessionSubscriptions subscriptions , String text ) throws Exception {
25
+ GraphQLSingleInvocationInput graphQLSingleInvocationInput = createInvocationInput (session , text );
23
26
subscribe (
24
27
session ,
25
- input .getQueryInvoker ().query (
26
- input .getInvocationInputFactory ().create (
27
- input .getGraphQLObjectMapper ().readGraphQLRequest (text )
28
- )
29
- ),
28
+ input .getQueryInvoker ().query (graphQLSingleInvocationInput ),
30
29
subscriptions ,
31
30
UUID .randomUUID ().toString ()
32
31
);
33
32
}
34
33
34
+ private GraphQLSingleInvocationInput createInvocationInput (Session session , String text ) throws IOException {
35
+ GraphQLRequest graphQLRequest = input .getGraphQLObjectMapper ().readGraphQLRequest (text );
36
+ HandshakeRequest handshakeRequest = (HandshakeRequest ) session .getUserProperties ()
37
+ .get (HandshakeRequest .class .getName ());
38
+
39
+ return input .getInvocationInputFactory ().create (graphQLRequest , session , handshakeRequest );
40
+ }
41
+
35
42
@ Override
36
43
protected void sendDataMessage (Session session , String id , Object payload ) {
37
44
sender .send (session , payload );
0 commit comments