I am developing an Xcode app with a job feed, with profile view, with chat eg. I fetch using federatet queries to my microservices thru Apollo Router. Infront of the Apollo Router i Have a Kong that adds a X user ID, that the microservices use for personalized feed and other user info. The info is stored with SwiftData. My thought is that i should add a better way of controlling when i need to fetch. I have a “lastupdateAPI” with different entities (profile, profile picture eg). So when nothing has changed we do not fetch. But rather then using a own API for this, isnt ETag better? Or is it any other recommendations with Xcode Swiftui. Good strategies for not fetching what i already have?
If you intent is to detect a change on your SwiftData store without adding your own data structure, consider observing ModelContext.disSave notification and looking into the SwiftData history from there. The following technical resources cover the what and how:
The discussion in the following posts may help as well:
-
Is it possible to track history using HistoryDescriptor in SwiftData?
-
Does SwiftData History API (introduced in WWD24) allows to also monitor value changes?
Best,
——
Ziqiao Chen
Worldwide Developer Relations.