DateAdapter Scalar is not converting string -> Date

I am using v3 (3.6.2) of the kotlin apollo SDK.

I have the following custom scalars defined in my build.gradle file:

apollo {
    mapScalar("JSON", "kotlin.String", "")
    mapScalar("Datetime", "java.util.Date", "com.apollographql.apollo3.adapter.DateAdapter")

I am expected the DateAdapter to translate a String to a java.util.Date object. However the date objects are still remaining strings. Here is an example: "2022-10-17T10:57:52". I am expecting this string to be converted to a Date object, but it’s remaining a string. Is there a way to ensure that this gets parsed as a Date via the custom scalar?


Hi! :wave:

This should definitely work. The fields of type Datetime in your operations should be generated as java.util.Date in your models, is it not the case? Just to confirm, did you import the com.apollographql.apollo3:apollo-adapters dependency in your build.gradle file? If not the generated code shouldn’t compile.