Problem with ArgumentValue serialization by GraphQLRequest (GraphQLRequest#toHttpJsonBody)
used configuration
<resolverArgumentAnnotations>org.springframework.graphql.data.method.annotation.Argument</resolverArgumentAnnotations>
<useWrapperForNullableInputTypes>true</useWrapperForNullableInputTypes>
and I've go an error in test like below:
Invalid syntax with ANTLR error 'token recognition error at: '.s'' at line 1 column 70
I think the problem is that argument value is not serialized properly to the request body.
{"query":"query testTest { testTest: testTest(testInput: { testInput: org.springframework.graphql.data.ArgumentValue@6b0b9cb6 }){ result } }"}
Schema
type Query {
testTest(
testInput: TestInput!
): TestResult
input TestInput {
testInput: String
}
type TestResult {
result: String
}
}
Example test code:
TestInputGQL testInputGQL = TestInputGQL.builder()
.setTestInput(ArgumentValue.ofNullable("testValue"))
.build();
TestResultResponseProjection testResultResponseProjection = new TestResultResponseProjection().result();
GraphQLRequest graphQLRequest = new GraphQLRequest(
TestTestQueryRequest.builder().setTestInput(testInputGQL).build(),
testResultResponseProjection
);
TestTestQueryResponse graphqlResponse = sendGraphQLQuery(
graphQLRequest
)
.then()
.statusCode(200)
.extract()
.body()
.as(TestTestQueryResponse.class);
expected
{"query":"query testTest { testTest: testTest(testInput: { testInput: "testValue" }){ result } }"}
or skipped value when is ommited
Environment and Setup
- graphql-java-codegen version: 5.10.0
- Build tool: Maven
Had a look.
As indicated and suspected: ArgumentValue is not serializable, which seems to be the root cause.
I'm unsure how to fix this, as ArgumentValue is purposefully not part of the dependencies, so it doesn't seem possible to add a custom serializer. Any suggestions would be appreciated.
The only idea I can come up with, is contrubuting to spring-graphql, making it serializable.