So, another cache question. Our query for chat mes...
# apollo-kotlin
s
So, another cache question. Our query for chat messages looks like this:
Copy code
chat(until: Instant): Chat!
And I realize now that the cache also respects the input to
until
, and caches the responses here separately. This means that my original plan to watch the query with any input doesn’t look like it’s working atm 😄 Is there a way to alter this, perhaps manually? The cache in our case does not depend on that input at all, they should be shared for any input for this one query.
I feel like what I’d need here is to do something special with programmatic cache IDs, to maybe make that query disregard the input completely, which looks a bit daunting tbh, and I’d at least try to avoid it if possible. For now I just reused
populateCacheWithNewMessages
from here which now takes a list, and puts it in the cache for the query with a null input, manually after the response is successfully back. So manually populating the cache for the
null
input version of the query, which is the one which I am watching seems to work fine 😊 As long as I make sure to filter the duplicates by doing this however
val mergedMessages: Set<ChatMessagesQuery.Data.Chat.Message> = (data.chat.messages + message).toSet()
Will do this for now at least I think, but it certainly feels like a bit of a hack 😳