Hi Team, just giving the new `normalised-cache` a ...
# apollo-kotlin
i
Hi Team, just giving the new
normalised-cache
a go as need the pagination feat however, im getting:
Copy code
Unexpected JSON token at offset 153301: Encountered an unknown key 'scalarMapping' at path: $.normalizedPath
Use 'ignoreUnknownKeys = true' in 'Json {}' builder to ignore unknown keys.
JSON input: .....lizedPath":"schema.graphqls","scalarMapping":{},"generateDat.....
b
👋 are you on Apollo Kotlin 4.2.0?
i
no
4.0.0
I believe 4.2.0 require Kotlin 2.0 which we cant upgrade to atm..
b
I think that may be the reason, because the new normalized cache depends on
4.2.0
. > 4.2.0 require Kotlin 2.0 which we cant upgrade to atm Are you targeting a native target?
i
yeah, we're
btw, does prev normalized cache supports pagination?
b
ah that's a bummer. Indeed in that case, you'll need to update your Kotlin version to 2.1+ before you can upgrade to Apollo 4.2.0
does prev normalized cache supports pagination
no that's only in the new one
i
thats a huge upgrade which we wont have time to deal with for now. its a shame because it'll have been good to remove Realm DB and completely rely on normalized cache. The challenge with current normalized cache is that it doesnt play well with pagination
b
Yeah that's kind of sad 😞. Is Realm the reason why you can't upgrade Kotlin or something else?
i
We attempted the upgrade 2 weeks ago, had to deal with a bunch of issues so had to revert due to time. There are other 3rd party deps that will simply become buggy and have to spend hours/days trying to fix. I'll need 2 days set apart just to deal with the complete upgrade
b
I see.
i
qq: for things like
query { myQuery(first: 10, cursor: string)} { id }
, this wont work at present? I can see in the Apollo cache intelliJ plugin that data are stored this way so i wonder why it wont pick such payload up
b
sorry, what doesn't work here?
i
querying using the
after
argument doesnt work.
but it stores the data correctly in the cache
b
I think it works but the problem is you're probably watching the query of the first page in your app, right? So when you fetch subsequent pages, your UI doesn't know.
that's what the pagination support does: it merges the pages in the same record, so your watchers will receive the whole list.
i
gotcha! will give it a go and revert if any other questions
b
👍 don't hesitate!
i
I'm running into this exact issue, fast-forward to 2025, whats a compatible
compose-compiler
version for Kotlin 2.0?
b
nowadays you're supposed to use the
org.jetbrains.kotlin.plugin.compose
Gradle plugin (same version as KGP)
i
I've tried
1.8.1
which is the latest, but seem to be getting another flavor of the IOS_ARM2 error:
Copy code
java.lang.ExceptionInInitializerError (no error message)
> org.jetbrains.kotlin.konan.target.KonanTarget$IOS_ARM32
that didnt work: Exception java.lang.ArrayStoreException: org.jetbrains.kotlin.konan.target.KonanTarget$IOS_ARM32 [in thread "Daemon worker Thread 9"]
b
Hmm that doesn't ring a bell
i
its the same error msg in the link shared above
b
I would probably try to create a new empty project from one of the recent templates, and try to spot the differences with yours
i
@bod cheers Managed to sort those issues and got android working okay. This is a KMM project so we need the module to work in other
arch
like
iosARM64
Build is failing in iOS atm
Copy code
KLIB resolver: could not find modules-2/files-2.1/com.apollographql.cache/normalized-cache-sqlite-iossimulatorarm64/1.0.0-alpha.2/52c5971a0d909fcd67120f39e8947e5a53ab6ffb/normalized-cache-sqlite-iosSimulatorArm64Main-1.0.0-alpha.2.klib in .konan/kotlin-native-prebuilt-macos-aarch64-2.0.21/klib/platform/ios_simulator_arm64]
b
Good to hear about Android. For iOS, curious, we do publish that target: here/here
i
let me give that a go
ok think i know whats going on:
Copy code
KLIB resolver: Skipping '/modules-2/files-2.1/com.apollographql.cache/normalized-cache-sqlite-iossimulatorarm64/1.0.0-alpha.2/52c5971a0d909fcd67120f39e8947e5a53ab6ffb/normalized-cache-sqlite-iosSimulatorArm64Main-1.0.0-alpha.2.klib'. Incompatible ABI version. The current default is '1.8.0', found '1.201.0'. The library was produced by '2.1.21' compiler.
the new normalized-cache-sqlite was compiled using v2.1.21 which is abit high considering other modules yet to catchup. We are now on Kotlin 2.0.21. That's the version that works for us with other 3rd parties we've got.
Do you have a version compiled on v2.0.21?
b
No, not a recent one. But since the cache needs Apollo 4.2.0, and that one is also compiled with Kotlin 2.1, I think that's not possible.
i
4.2.0 works with kotlin "2.0.21
b
hmm that's odd, it shouldn't (for native)
i
honestly, it would have been so cool to not have to use RealmDB. Pagination on the cache level is a key use-case. We'll simply use apolloclient for network-only call in that case.
b
I 100% agree, I hope you'll find a way to escape your dependency hell eventually 🙂 And get rid of Realm.
i
cheers!
b
(By the way, you can star this issue which would help Apollo and other libs to be compatible with older versions of Kotlin native)
i
nice one! 👍