smallrye / smallrye-graphql

Implementation for MicroProfile GraphQL
Apache License 2.0
160 stars 91 forks source link

GraphQL field batching failing on subscription #2164

Open cristianonicolai opened 2 months ago

cristianonicolai commented 2 months ago

I'm having an issue when using a @Subscription along with a batch @Source method. Seems like a potential regression on graphql. I've got a reproducer project here: https://github.com/cristianonicolai/graphql-playground . I also noticed that removing the batch, using a single entity as @Source code works fine, see https://github.com/cristianonicolai/graphql-playground/blob/main/src/main/java/org/acme/GraphQLResource.java#L41

Batch is not mandatory for the PlanDTO type in the subscription, since it will always return a single value. But since the same type is reused for a query, where batching makes sense, see plans query in the reproducer.

The issue started to happen once trying to upgrade Quarkus from version 3.12.3 to 3.13.3 (graphql-java 21.3 to 22.1.).

Although in the reproduces it logs an error BackPressureFailure: Could not emit tick 1 due to lack of requests, there is no error in the logs in the real application. It silintly fails to receive any items in the subscriber. Last related log in the app is:

2024-08-26 22:39:10,990 INFO  [io.sma.graphql] (vert.x-eventloop-thread-2) SRGQL011006: Payload Out [ExecutionResponse->ExecutionResultImpl{errors=[], data=graphql.execution.reactive.SubscriptionPublisher@713fd348, dataPresent=true, extensions=null}]
simenbw commented 1 month ago

I was also facing this issue. It seems to be an error in graphql-java 22.1 https://github.com/graphql-java/graphql-java/issues/3662

I locked graphql-java to version 22.2 and that fixed it. I see smallrye-graphql already have bump version to 22.2 So issue seems to be that quarkus has not bumped smallrye-graphql version

jmartisk commented 1 month ago

Thanks @simenbw for investigating this! If a graphql-java update fixes the problem, that's great. Unfortunately, I tried getting SmallRye GraphQL 2.10 (and thus graphql-java 22.2) into Quarkus 3.15, but it was rejected. So this will be fixed in Quarkus 3.16.

jmartisk commented 1 month ago

Or given that 3.15 will be LTS, I may be able to squeeze the graphql-java update there after all, into a later micro update. I'll try that :)