Colton Idle
03/06/2023, 1:35 PMAny
. Is there something I'm missing here?Colton Idle
03/06/2023, 1:50 PM.addCustomScalarAdapter(Date.type, DateAdapter())
doesn't compile.mbonnin
03/06/2023, 1:51 PMapollo {
service("service") {
mapScalar("Date", "java.util.Date", "com.apollographql.apollo3.adapter.DateAdapter")
}
}
Date
is not in the GraphQL spec so there's nothing special about it, it could be "Any" type by defaultjava.util.Date
though and prefer kotlinx.datetime.Instant
Colton Idle
03/06/2023, 1:58 PM2023-02-22T20:32:04.000Z
is?mbonnin
03/06/2023, 1:58 PMStylianos Gakis
03/06/2023, 1:58 PMISO8601
spec, then you’re ok with either.mbonnin
03/06/2023, 1:59 PMZ
part of iso8601? I never knowStylianos Gakis
03/06/2023, 1:59 PMmbonnin
03/06/2023, 2:00 PMval instant = Instant.parse("2023-02-22T20:32:04.000Z")
println(instant.epochSeconds)
kotlinx.datetime.Instant
and save you future Java Date troublesColton Idle
03/06/2023, 2:02 PMmbonnin
03/06/2023, 2:02 PMdependencies {
implementation("com.apollographql.apollo3:apollo-adapters")
}
apollo {
service("service") {
mapScalar("Date", "kotlinx.datetime.Instant", "com.apollographql.apollo3.adapter.KotlinxInstantAdapter")
}
}
Colton Idle
03/06/2023, 2:03 PMmbonnin
03/06/2023, 2:03 PMColton Idle
03/06/2023, 2:03 PM.addCustomScalarAdapter(Date.type, KotlinxInstantAdapter)
mbonnin
03/06/2023, 2:03 PMmapScalar
will "burn" the adapters in the codegenColton Idle
03/06/2023, 2:04 PMmbonnin
03/06/2023, 2:05 PMmapScalar(String, String)
without the third parameter that leaves the adapter to be registered at runtime)Colton Idle
03/06/2023, 2:17 PMmbonnin
03/06/2023, 2:19 PMColton Idle
03/06/2023, 2:20 PMmbonnin
03/06/2023, 2:21 PMColton Idle
03/06/2023, 2:23 PMmbonnin
03/06/2023, 2:24 PMColton Idle
03/06/2023, 2:27 PMmbonnin
03/06/2023, 2:29 PMapollo-adapters
has an API dependency on kotlinx-datetime
so it "should" be seenStylianos Gakis
03/06/2023, 2:30 PMColton Idle
03/06/2023, 2:30 PMisBefore
method? I gotta use toJavaInstant? interesting...mbonnin
03/06/2023, 2:37 PM.compareTo
Colton Idle
03/06/2023, 2:38 PM2023-02-22T20:32:04.000Z
so I guess the Z is the culprit making it crash?bod
03/10/2023, 6:56 AMmapScalarToKotlinString
in the grade configuration. But in the end you really don't want a string but some kind of date object, right? If you're going to do a conversion, you might as well do it inside an Apollo adapter (if none of the provided ones work for you, you can write a custom adapter).Stylianos Gakis
03/10/2023, 6:59 AMHad to move to JavaLocalDateTimeAdapter instead.
Why?
Colton Idle
03/11/2023, 8:41 PM