Hi Team! Any idea whats causing this runtime error...
# apollo-kotlin
i
Hi Team! Any idea whats causing this runtime error: I'm using
com.apollographql.apollo:apollo-normalized-cache-sqlite
v4.0.0 which matches
apollo
version
Copy code
Apollo: unhandled exception
java.lang.Exception: Unable to read a record from the database
at com.apollographql.apollo.cache.normalized.sql.SqlNormalizedCache.loadRecord(SqlNormalizedCache.kt:25)
Caused by: android.database.sqlite.SQLiteException: Can't downgrade database from version 3 to 1
b
I think from previous conversations that you were trying the new cache. Which upgraded the database to the new format. Now the previous version is unable to read it anymore.
Deleting the database file should do it.
i
yep! that did fixed it! cheers man!
👍 1
Another qq mate (dont recall if you already answer in our last convo) can you write into paginated cache like so via the
apolloStore.writeOperation
? Actually, was able to write, but the
Copy code
messages({"after":"","first":20,"receiver_id":12,"sender_id":25})
I attempted it but couldnt find the data once written It still maintained the old data
b
Hmm yes when you do this, it should replace the current list with the one you pass.
i
right i know the
edges
is being updated correctly. my guess however is that the
first
argument in the paginated when querying is not dynamic, it'll always look for
first:20
for example and there's nothing of such in the cache db when i used the intelliJ viewer.
I wonder if there's anyway around this..
b
What's supposed to happen is that you should see a
messages({"receiver_id":12,"sender_id":25})
field in the cache. I.e.
after
and
first
should be omitted.
i
awesome! just removed the
first:20
arg from the actual query that way it returned the updated data each time.
🎉 1
appreciate it!
of course that will impact perf depending on
messages
count when
first
is removed 😀
@bod how do we force
*.wal
file to be immediately sync'd with the actual db on ios? As you prob know,
writes
on iOS goes into *.wal` file whilst preserving the actual db for
reads
. This doesnt immediatly sync up which leads to two sets of data. At runtime, the wal file is not available for reads, causing app to fetch from network.
How can we ensure immediate writes are made available to actual db so it can be part of the data when querying? Looked at the
apolloStore
api, cant see anything explicitly enforcing this
Screenshot 2025-06-07 at 22.07.47.png
b
as far as I know this should just work, without a need to do anything explicit