11package graphql .servlet .internal ;
22
3+ import graphql .servlet .GraphQLSingleInvocationInput ;
4+
35import javax .websocket .Session ;
46import javax .websocket .server .HandshakeRequest ;
57import java .io .IOException ;
@@ -20,18 +22,23 @@ public FallbackSubscriptionProtocolHandler(SubscriptionHandlerInput subscription
2022
2123 @ Override
2224 public void onMessage (HandshakeRequest request , Session session , WsSessionSubscriptions subscriptions , String text ) throws Exception {
25+ GraphQLSingleInvocationInput graphQLSingleInvocationInput = createInvocationInput (session , text );
2326 subscribe (
2427 session ,
25- input .getQueryInvoker ().query (
26- input .getInvocationInputFactory ().create (
27- input .getGraphQLObjectMapper ().readGraphQLRequest (text )
28- )
29- ),
28+ input .getQueryInvoker ().query (graphQLSingleInvocationInput ),
3029 subscriptions ,
3130 UUID .randomUUID ().toString ()
3231 );
3332 }
3433
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+
3542 @ Override
3643 protected void sendDataMessage (Session session , String id , Object payload ) {
3744 sender .send (session , payload );
0 commit comments