Created
March 9, 2021 11:54
-
-
Save morgz/596b3ee72d2a43f385724e71e379d93d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ApolloService.shared.client.store.withinReadWriteTransaction({ transaction in | |
let deletedDroidId = "..." | |
// | |
// Update the Query | |
// | |
let query = DroidListQuery() | |
// Update Cache for a Query on a deletion | |
try transaction.update(query: query) { (data: inout DroidListQuery.Data) in | |
// Filter out the deleted droid and set the queries entries to be | |
if let newEntries = data.entries?.filter({$0?.id != deletedDroidId}) { | |
data.entries? = newEntries | |
} | |
} | |
// | |
// Update an Object / Fragments which may reference this droid. | |
// | |
try transaction.updateObject(ofType: DroidMission.self, withKey: droidMissionId, { (mission: inout DroidMission) in | |
mission.droid = nil | |
}) | |
}, callbackQueue: DispatchQueue.global(qos: .background)) { completion in | |
print("\n\nApollo Cache Completion: \(completion)") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment