Open andreloeffelmann opened 7 months ago
I'm not sure if its resolves your issue, but my implementation uses graphql-java-extended-scalars.
So I've setup DateTime in plugin config
<customTypesMapping>
<DateTime>java.time.OffsetDateTime</DateTime>
And added ExtendedScalars.DateTime to my auto config
import graphql.scalars.ExtendedScalars;
@AutoConfiguration
public class GraphqlAutoConfiguration {
@Bean
public RuntimeWiringConfigurer runtimeWiringConfigurer() {
return wiringBuilder -> wiringBuilder.scalar(ExtendedScalars.DateTime)
and I don't have this stringify issue.
After all, GraphQL only support very few types out of the box, date not being one of them.
Issue Description
If an input field for a mutation is e.g. of
DateTime
type, the generated GraphQL mutation contains the stringified datetime not in escaped strings which leads to a syntax parsing error at the remote GraphQL service. This happens becauseGraphQLRequestSerializer.java
does not escape these types inpublic static String getEntry(Object input, boolean useObjectMapper)
method and just invokes.toString()
on the value.Example mutation:
But expected:
A possible solution: Support
java.time.Temporal
andjava.time.TemporalAmount
types inpublic static String getEntry(Object input, boolean useObjectMapper)
method ofGraphQLRequestSerializer.java
, by adapting it e.g. like this: