Skip to content

"vc" is null in GraphQL when using CompletionStage #44762

Open
@phillip-kruger

Description

Describe the bug

When using this query in GraphQL:

{
  person(id: 1){
    id
    names
    currencyCode
    scores{
      name
      value
    }
  	exchangeRate(against: GBP){
      rate
    }
  }
  weather(city: "London"){
    currentTemp
    description
  }
}

with the following graphql services:

@Query
    public CompletionStage<Person> getPerson(long id){
        //return personService.getPerson(id);
        return CompletableFuture.supplyAsync(()-> personService.getPerson(id));
    }
public List<List<Score>> getScores(@Source List<Person> people){
        List<String> ids = people.stream().map(Person::getIdNumber).collect(Collectors.toList());
        return scoreService.getScores(ids);
    }
    
    public ExchangeRate getExchangeRate(@Source Person person, CurrencyCode against){
        return exchangeRateService.getExchangeRate(against, person.getCurrencyCode());
    }
@Query
    public CompletionStage<Weather> getWeather(String city){
        return weatherService.getFutureWeather(city);
    }

I get this exception:

2024-11-27 13:13:23,074 ERROR [io.sma.graphql] (ForkJoinPool.commonPool-worker-7) SRGQL012000: Data Fetching Error: java.lang.NullPointerException: Cannot invoke "io.vertx.core.Context.executeBlocking(java.util.concurrent.Callable)" because "vc" is null
        at io.quarkus.smallrye.graphql.runtime.spi.datafetcher.BlockingHelper.runBlocking(BlockingHelper.java:28)
        at io.quarkus.smallrye.graphql.runtime.spi.datafetcher.QuarkusDefaultDataFetcher.invokeAndTransformBlocking(QuarkusDefaultDataFetcher.java:111)
        at io.quarkus.smallrye.graphql.runtime.spi.datafetcher.QuarkusDefaultDataFetcher.invokeAndTransform(QuarkusDefaultDataFetcher.java:47)
        at io.smallrye.graphql.execution.datafetcher.AbstractDataFetcher.get(AbstractDataFetcher.java:70)
        at graphql.execution.ExecutionStrategy.invokeDataFetcher(ExecutionStrategy.java:533)
        at graphql.execution.ExecutionStrategy.fetchField(ExecutionStrategy.java:497)
        at graphql.execution.ExecutionStrategy.fetchField(ExecutionStrategy.java:438)
        at graphql.execution.ExecutionStrategy.resolveFieldWithInfo(ExecutionStrategy.java:397)
        at graphql.execution.ExecutionStrategy.getAsyncFieldValueInfo(ExecutionStrategy.java:335)
        at graphql.execution.ExecutionStrategy.executeObject(ExecutionStrategy.java:214)
        at graphql.execution.ExecutionStrategy.completeValueForObject(ExecutionStrategy.java:963)
        at graphql.execution.ExecutionStrategy.completeValue(ExecutionStrategy.java:701)
        at graphql.execution.ExecutionStrategy.completeField(ExecutionStrategy.java:653)
        at graphql.execution.ExecutionStrategy.lambda$resolveFieldWithInfo$7(ExecutionStrategy.java:401)
        at io.smallrye.context.impl.wrappers.SlowContextualFunction.apply(SlowContextualFunction.java:21)
        at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
        at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
        at java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2179)
        at io.smallrye.context.impl.wrappers.SlowContextualConsumer.accept(SlowContextualConsumer.java:21)
        at io.smallrye.mutiny.helpers.UniCallbackSubscriber.onItem(UniCallbackSubscriber.java:73)
        at io.smallrye.mutiny.operators.uni.UniOnTermination$UniOnTerminationProcessor.onItem(UniOnTermination.java:39)
        at io.smallrye.mutiny.operators.uni.UniOnCancellation$UniOnCancellationProcessor.onItem(UniOnCancellation.java:49)
        at io.smallrye.mutiny.operators.uni.UniOnItemOrFailureFlatMap$UniOnItemOrFailureFlatMapProcessor.onItem(UniOnItemOrFailureFlatMap.java:56)
        at io.smallrye.mutiny.operators.uni.builders.DefaultUniEmitter.complete(DefaultUniEmitter.java:37)
        at io.quarkus.smallrye.graphql.runtime.spi.datafetcher.AbstractAsyncDataFetcher.lambda$invokeAndTransform$1(AbstractAsyncDataFetcher.java:80)
        at io.smallrye.mutiny.context.BaseContextPropagationInterceptor$ContextualizedTriConsumer.lambda$accept$0(BaseContextPropagationInterceptor.java:353)
        at io.smallrye.context.impl.wrappers.SlowContextualExecutor.execute(SlowContextualExecutor.java:19)
        at io.smallrye.mutiny.context.BaseContextPropagationInterceptor$ContextualizedTriConsumer.accept(BaseContextPropagationInterceptor.java:353)
        at io.smallrye.mutiny.groups.UniOnItemOrFailure.lambda$transformToUni$4(UniOnItemOrFailure.java:167)
        at io.smallrye.context.impl.wrappers.SlowContextualConsumer.accept(SlowContextualConsumer.java:21)
        at io.smallrye.mutiny.operators.uni.builders.UniCreateWithEmitter.subscribe(UniCreateWithEmitter.java:22)
        at io.smallrye.mutiny.operators.AbstractUni.subscribe(AbstractUni.java:36)
        at io.smallrye.mutiny.operators.uni.UniOnItemOrFailureFlatMap$UniOnItemOrFailureFlatMapProcessor.performInnerSubscription(UniOnItemOrFailureFlatMap.java:99)
        at io.smallrye.mutiny.operators.uni.UniOnItemOrFailureFlatMap$UniOnItemOrFailureFlatMapProcessor.onItem(UniOnItemOrFailureFlatMap.java:54)
        at io.smallrye.mutiny.operators.uni.builders.UniCreateFromCompletionStage$CompletionStageUniSubscription.forwardResult(UniCreateFromCompletionStage.java:63)
        at java.base/java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:863)
        at java.base/java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:841)
        at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
        at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1773)
        at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)

Expected behavior

This should work

Actual behavior

It result in an exception

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

No response

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions