@@ -141,7 +141,7 @@ final class StorageEngine: StorageEngineBehavior {
141
141
self . log. verbose ( " \( #function) syncing mutation for \( savedModel) " )
142
142
self . syncMutation ( of: savedModel,
143
143
mutationType: mutationType,
144
- queryPredicate : condition,
144
+ predicate : condition,
145
145
syncEngine: syncEngine,
146
146
completion: completion)
147
147
} else {
@@ -246,6 +246,7 @@ final class StorageEngine: StorageEngineBehavior {
246
246
} else {
247
247
self . syncDeletions ( of: modelType,
248
248
withModelIds: modelIds,
249
+ predicate: predicate,
249
250
syncEngine: syncEngine,
250
251
completion: syncCompletionWrapper)
251
252
}
@@ -351,17 +352,30 @@ final class StorageEngine: StorageEngineBehavior {
351
352
// we start to pass in the predicate
352
353
private func syncDeletions< M: Model > ( of modelType: M . Type ,
353
354
withModelIds modelIds: [ Model . Identifier ] ,
355
+ predicate: QueryPredicate ? = nil ,
354
356
syncEngine: RemoteSyncEngineBehavior ,
355
357
completion: @escaping DataStoreCallback < Void > ) {
356
358
var mutationEvents : Set < Model . Identifier > = [ ]
357
359
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
+
358
371
for modelId in modelIds {
359
372
let mutationEvent = MutationEvent ( id: UUID ( ) . uuidString,
360
373
modelId: modelId,
361
374
modelName: modelType. modelName,
362
375
json: " {} " ,
363
376
mutationType: . delete,
364
- createdAt: Date ( ) )
377
+ createdAt: Date ( ) ,
378
+ graphQLFilterJSON: graphQLFilterJSON)
365
379
366
380
let mutationEventCallback : DataStoreCallback < MutationEvent > = { result in
367
381
switch result {
@@ -385,14 +399,14 @@ final class StorageEngine: StorageEngineBehavior {
385
399
@available ( iOS 13 . 0 , * )
386
400
private func syncMutation< M: Model > ( of savedModel: M ,
387
401
mutationType: MutationEvent . MutationType ,
388
- queryPredicate : QueryPredicate ? = nil ,
402
+ predicate : QueryPredicate ? = nil ,
389
403
syncEngine: RemoteSyncEngineBehavior ,
390
404
completion: @escaping DataStoreCallback < M > ) {
391
405
let mutationEvent : MutationEvent
392
406
do {
393
407
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 )
396
410
}
397
411
398
412
mutationEvent = try MutationEvent ( model: savedModel,
0 commit comments