Environment:
OpenLiberty(25.0.0.12 -> https://openliberty.io/start/#gradle) with
mpGraphQL-2.0featureMicroProfile GraphQL API 2.0
Java 21
I'm trying to use batch resolvers in MicroProfile GraphQL 2.0 with OpenLiberty, but the batch resolver doesn't seem to be invoked even though the server logs indicate it should be.
[WARNUNG ] SRGQL010002: Operation [subName] also exist as a batch operation - ignoring the non-batch operation
So both Resolver methods are recognized, but when calling the API it throws NPE when accessing the 'subName':
query Test {
testDto {
name
subName
}
}
Results in:
{
"errors": [
{
"message": "Server Error",
"locations": [
{
"line": 4,
"column": 5
}
],
"path": [
"testDto",
"subName"
],
"extensions": {
"exception": "java.lang.NullPointerException",
"classification": "DataFetchingException",
"code": "null-pointer"
}
}
],
"data": {
"testDto": {
"name": "P1",
"subName": null
}
}
}
I have a simple GraphQL API with both a single resolver and a batch resolver for the same field:
@GraphQLApi
public class TestGQL {
@Query
public TestDto getTestDto() {
return new TestDto("P1");
}
@Query
public List<TestDto> getTestDtos() {
List<TestDto> result = new ArrayList<>();
result.add(new TestDto("P2"));
result.add(new TestDto("P3"));
return result;
}
@Name("subName")
public String getSubName(@Source TestDto testDto) {
return testDto.name + "_SingleResolver";
}
@Name("subName")
public List<String> getSubNameBatch(@Source List<TestDto> testDtos) {
return testDtos.stream().map(p -> p.name + "_BatchResolver").toList();
}
public static class TestDto {
public String name;
public TestDto(String name) {
this.name = name;
}
}
}
Enabled features in my server.xml
<featureManager>
<feature>jakartaee-10.0</feature>
<feature>microProfile-7.0</feature>
<feature>mpGraphQL-2.0</feature>
</featureManager>
Dependencies in my build.gradle:
dependencies {
// provided dependencies
providedCompile 'jakarta.platform:jakarta.jakartaee-api:10.0.0'
providedCompile 'org.eclipse.microprofile:microprofile:7.0'
// https://mvnrepository.com/artifact/org.eclipse.microprofile.graphql/microprofile-graphql-api
implementation 'org.eclipse.microprofile.graphql:microprofile-graphql-api:2.0'
}
Question:
Is there something misconfigured in my setup, or is this a bug in the OpenLiberty implementation of MicroProfile GraphQL?