graphql-java-kickstart/graphql-java-servlet

Subscription deserialization error when not using Apollo protocol

WenSteven opened this issue · 1 comments

Describe the bug
java.lang.IllegalArgumentException: Cannot construct instance of graphql.kickstart.execution.GraphQLRequest (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('{ "query": "subscription CustomerImportSub { stockQuotes(stockCodes:[12]) {taskCount completedCount}}", "variables": {} }') at [Source: UNKNOWN; line: -1, column: -1] at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:4202) ~[jackson-databind-2.11.0.jar:2.11.0] at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:4133) ~[jackson-databind-2.11.0.jar:2.11.0] at graphql.kickstart.execution.subscriptions.GraphQLSubscriptionMapper.readGraphQLRequest(GraphQLSubscriptionMapper.java:16) ~[graphql-java-servlet-9.1.0.jar:na]

To Reproduce
this demo also get same error!!

I think GraphQLSubscriptionMapper.readGraphQLRequest should use ObjectMapper#readValue not convertValue

Screenshots

https://github.com/graphql-java-kickstart/graphql-spring-boot/tree/master/example-graphql-subscription

this demo has same error

GraphiQL uses the Apollo protocol, which is also the one I use in my projects, and in that case the subscription mapper is working fine as indicated. Judging by the code it could be that when you're not using Apollo protocol but it uses the FallbackSubscriptionConsumer you run into this problem. The subscription mapper should support both cases.