You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 because GraphQLRequestSerializer.java does not escape these types in public static String getEntry(Object input, boolean useObjectMapper) method and just invokes .toString() on the value.
A possible solution:
Support java.time.Temporal and java.time.TemporalAmount types in public static String getEntry(Object input, boolean useObjectMapper) method of GraphQLRequestSerializer.java, by adapting it e.g. like this:
publicstaticStringgetEntry(Objectinput, booleanuseObjectMapper) {
if (input == null) {
returnnull;
} elseif (useObjectMapper) {
returnobjectMapperWriteValueAsString(input);
} elseif (inputinstanceofCollection<?>) {
returnserializeCollection((Collection<?>) input, useObjectMapper);
} elseif (inputinstanceofMap<?, ?>) {
returnserializeMap((Map<?, ?>) input, useObjectMapper);
} elseif (inputinstanceofMap.Entry<?, ?>) {
returnserializeMapEntry((Map.Entry<?, ?>) input, useObjectMapper);
} elseif (inputinstanceofEnum<?>) {
returnserializeEnum((Enum<?>) input);
} elseif (inputinstanceofString) {
returnescapeJsonString(input.toString());
} elseif (input.getClass().getName().equals("scala.Some")) { // TODO: move to Scala Serializer// Currently, option only supports primitive types, so that's fine.// Now, this kind of case will appear if and only if Seq[Option[Int]] isreturninput.toString().replace("Some(", "").replace(")", "");
} elseif (input.getClass().getName().equals("scala.None$")) {
returnnull;
} elseif (inputinstanceofTemporal || inputinstanceofTemporalAmount) {
returnescapeJsonString(input.toString());
} else {
returninput.toString();
}
}
The text was updated successfully, but these errors were encountered:
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 because
GraphQLRequestSerializer.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:The text was updated successfully, but these errors were encountered: