bug: java.lang.NoSuchMethodError on executing a graphql query against an apollo server
Expected behavior
Retrieve data from apollo server with the dgs client.
Actual behavior
I am getting the following error:
ERROR 366844 --- [nio-9102-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.util.concurrent.ExecutionException: java.lang.NoSuchMethodError: 'reactor.util.context.ContextView reactor.core.publisher.MonoSink.contextView()'] with root cause
java.lang.NoSuchMethodError: 'reactor.util.context.ContextView reactor.core.publisher.MonoSink.contextView()'
at reactor.netty.http.client.HttpClientConnect$HttpObserver.<init>(HttpClientConnect.java:329) ~[reactor-netty-http-1.0.18.jar:1.0.18]
at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect.lambda$subscribe$0(HttpClientConnect.java:259) ~[reactor-netty-http-1.0.18.jar:1.0.18]
at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:57) ~[reactor-core-3.4.10.jar:3.4.10]
at reactor.core.publisher.FluxRetryWhen.subscribe(FluxRetryWhen.java:77) ~[reactor-core-3.4.10.jar:3.4.10]
at reactor.core.publisher.MonoRetryWhen.subscribeOrReturn(MonoRetryWhen.java:46) ~[reactor-core-3.4.10.jar:3.4.10]
at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:57) ~[reactor-core-3.4.10.jar:3.4.10]
at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect.subscribe(HttpClientConnect.java:272) ~[reactor-netty-http-1.0.18.jar:1.0.18]
at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64) ~[reactor-core-3.4.10.jar:3.4.10]
at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) ~[reactor-core-3.4.10.jar:3.4.10]
at reactor.core.publisher.Mono.subscribe(Mono.java:4361) ~[reactor-core-3.4.10.jar:3.4.10]
at reactor.core.publisher.Mono.subscribeWith(Mono.java:4476) ~[reactor-core-3.4.10.jar:3.4.10]
at reactor.core.publisher.Mono.subscribe(Mono.java:4193) ~[reactor-core-3.4.10.jar:3.4.10]
Steps to reproduce
I have the following code: Query to execute against apollo server:
query getMovie($id: ID!) {
movie(id: $id) {
id
name
}
}
and my dgs client code is:
public Movie findAll(String id) {
Movie movie = null;
try {
String URL = env.getProperty("graphql-movie.url");
WebClient webClient = WebClient.create(URL);
WebClientGraphQLClient client = MonoGraphQLClient.createWithWebClient(webClient);
Map<String, Object> variables = new HashMap<>();
variables.put("id", id);
String query = StreamUtils.copyToString(new ClassPathResource("movie.graphql").getInputStream(), Charset.defaultCharset());
Mono<GraphQLResponse> graphQLResponseMono = client.reactiveExecuteQuery(query, variables);
Mono<Movie> response = graphQLResponseMono.map(r -> r.extractValueAsObject("movie", Movie.class));
response.subscribe();
} catch (Exception e) {
e.printStackTrace();
}
return movie;
}
I am using dgs framework 5.0.5 version (but the same error occurs with any other older versions). I only could execute this query with spring-boot 2.6.6 or lower versions. When I upgrade spring-boot version to 2.6.7 or higher I get the error mentioned above, and the query is not even getting to the apollo server. I am not sure if this is a bug. I noticed that in the change from 2.6.6 to 2.6.7 release of spring-boot, the reactor package was updated.
Upgrade to Reactor 2020.0.18 https://github.com/spring-projects/spring-boot/issues/30596)
Any advice? For the moment I will continue using the 2.6.6 version of spring-boot.
any update of this?
Sorry, we haven't been able to look into this issue yet due to internal priorities. If you are blocked, feel free to open a PR if you have more context on how to fix this.
On Tue, Sep 13, 2022 at 9:02 AM Liam Osycka @.***> wrote:
any update of this?
— Reply to this email directly, view it on GitHub https://github.com/Netflix/dgs-framework/issues/1182#issuecomment-1245622047, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJ5JPXIAORICRS63CSWX4OTV6CQSNANCNFSM55WK74BA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
This looks like it was an issue between reactor-netty and reactor-core; reactor-netty likely needed 3.5.+, while on your classpath you only had reactor-core 3.4.x. You'd either want to override the reactor-core version in SBN, or try upgrading to the latest DGS, since we've bumped the reactor-core version in our BOM in the meantime.