Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with ArgumentValue serialization by GraphQLRequest (GraphQLRequest#toHttpJsonBody) #1474

Open
mka92 opened this issue Mar 7, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@mka92
Copy link

mka92 commented Mar 7, 2024

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
@mka92 mka92 added the bug Something isn't working label Mar 7, 2024
@rwo-trackunit
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants