While doing some changes today, we accidentally wr...
# apollo-kotlin
s
While doing some changes today, we accidentally wrote this piece of code:
Copy code
...
.fetchPolicy(FetchPolicy.CacheAndNetwork)
.execute()
And we were hit with the
com.apollographql.apollo.exception.DefaultApolloException: The operation returned multiple items, use .toFlow() instead of .execute()
exception. Now the question is, is there something we can do regarding avoiding this, besides either being careful to just not write this or working on some intricate linting tool which might be able to catch it? In past years I don't recall seeing this before so admittedly it is not a common scenario πŸ˜„
b
At least, in the new version of the cache, this value is deprecated πŸ˜…. So I guess that should help.
s
πŸ‘€πŸ‘€πŸ‘€ Say more? πŸ˜„
b
haha πŸ˜„ I mean this repo: https://github.com/apollographql/apollo-kotlin-normalized-cache Which is were the next version of the cache is worked on. You should definitely try it by the way!
s
Hmmm interesting. Would I expect a swap on the dependency and have this more or less at least work out of the box, or is the API shape completely changed which requires manual intervention to get it working again? I can't do it in the very near foreseeable future but yeah it would be nice for me to give this a try!
b
It's ... in between πŸ™‚ There are a few manual steps, but they are simple ones. I'd say, I would expect swapping to be a <1h job for most projects. You can peek at the migration guide to get an idea,
thank you color 1
One question is: is it ok for your app to lose the cached data when it updates? If not you'll need to implement some kind of migration step.
s
Ah no the cache just serves as a way to get quick responses when possible. On login/logout (which we force each day) everything is purged anyway. So it should be easy for us to experiment with it!
b
Perfect πŸ‘Œ