@@ -141,7 +141,7 @@ final class StorageEngine: StorageEngineBehavior {
141141 self . log. verbose ( " \( #function) syncing mutation for \( savedModel) " )
142142 self . syncMutation ( of: savedModel,
143143 mutationType: mutationType,
144- queryPredicate : condition,
144+ predicate : condition,
145145 syncEngine: syncEngine,
146146 completion: completion)
147147 } else {
@@ -246,6 +246,7 @@ final class StorageEngine: StorageEngineBehavior {
246246 } else {
247247 self . syncDeletions ( of: modelType,
248248 withModelIds: modelIds,
249+ predicate: predicate,
249250 syncEngine: syncEngine,
250251 completion: syncCompletionWrapper)
251252 }
@@ -351,17 +352,30 @@ final class StorageEngine: StorageEngineBehavior {
351352 // we start to pass in the predicate
352353 private func syncDeletions< M: Model > ( of modelType: M . Type ,
353354 withModelIds modelIds: [ Model . Identifier ] ,
355+ predicate: QueryPredicate ? = nil ,
354356 syncEngine: RemoteSyncEngineBehavior ,
355357 completion: @escaping DataStoreCallback < Void > ) {
356358 var mutationEvents : Set < Model . Identifier > = [ ]
357359
360+ var graphQLFilterJSON : String ?
361+ if let predicate = predicate {
362+ do {
363+ graphQLFilterJSON = try GraphQLFilterConverter . toJSON ( predicate)
364+ } catch {
365+ let dataStoreError = DataStoreError ( error: error)
366+ completion ( . failure( dataStoreError) )
367+ return
368+ }
369+ }
370+
358371 for modelId in modelIds {
359372 let mutationEvent = MutationEvent ( id: UUID ( ) . uuidString,
360373 modelId: modelId,
361374 modelName: modelType. modelName,
362375 json: " {} " ,
363376 mutationType: . delete,
364- createdAt: Date ( ) )
377+ createdAt: Date ( ) ,
378+ graphQLFilterJSON: graphQLFilterJSON)
365379
366380 let mutationEventCallback : DataStoreCallback < MutationEvent > = { result in
367381 switch result {
@@ -385,14 +399,14 @@ final class StorageEngine: StorageEngineBehavior {
385399 @available ( iOS 13 . 0 , * )
386400 private func syncMutation< M: Model > ( of savedModel: M ,
387401 mutationType: MutationEvent . MutationType ,
388- queryPredicate : QueryPredicate ? = nil ,
402+ predicate : QueryPredicate ? = nil ,
389403 syncEngine: RemoteSyncEngineBehavior ,
390404 completion: @escaping DataStoreCallback < M > ) {
391405 let mutationEvent : MutationEvent
392406 do {
393407 var graphQLFilterJSON : String ?
394- if let queryPredicate = queryPredicate {
395- graphQLFilterJSON = try GraphQLFilterConverter . toJSON ( queryPredicate )
408+ if let predicate = predicate {
409+ graphQLFilterJSON = try GraphQLFilterConverter . toJSON ( predicate )
396410 }
397411
398412 mutationEvent = try MutationEvent ( model: savedModel,
0 commit comments