From d3429cc5ecd59c5482e50ec77a3f4b56518c1a99 Mon Sep 17 00:00:00 2001 From: Vladimir Koptev <73164893+VladimirK-ah@users.noreply.github.com> Date: Mon, 4 Mar 2024 21:27:22 +0300 Subject: [PATCH] Feature/ContextIdentifier for the mutate queries (#281) Co-authored-by: Vladimir Koptev <> --- apollo-ios/Sources/Apollo/ApolloClient.swift | 3 ++- apollo-ios/Sources/Apollo/ApolloClientProtocol.swift | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/apollo-ios/Sources/Apollo/ApolloClient.swift b/apollo-ios/Sources/Apollo/ApolloClient.swift index e09bc65c9..f2f0df723 100644 --- a/apollo-ios/Sources/Apollo/ApolloClient.swift +++ b/apollo-ios/Sources/Apollo/ApolloClient.swift @@ -109,13 +109,14 @@ extension ApolloClient: ApolloClientProtocol { @discardableResult public func perform(mutation: Mutation, publishResultToStore: Bool = true, + contextIdentifier: UUID? = nil, context: RequestContext? = nil, queue: DispatchQueue = .main, resultHandler: GraphQLResultHandler? = nil) -> Cancellable { return self.networkTransport.send( operation: mutation, cachePolicy: publishResultToStore ? .default : .fetchIgnoringCacheCompletely, - contextIdentifier: nil, + contextIdentifier: contextIdentifier, context: context, callbackQueue: queue, completionHandler: { result in diff --git a/apollo-ios/Sources/Apollo/ApolloClientProtocol.swift b/apollo-ios/Sources/Apollo/ApolloClientProtocol.swift index 125cd950a..5c6180838 100644 --- a/apollo-ios/Sources/Apollo/ApolloClientProtocol.swift +++ b/apollo-ios/Sources/Apollo/ApolloClientProtocol.swift @@ -54,12 +54,14 @@ public protocol ApolloClientProtocol: AnyObject { /// - Parameters: /// - mutation: The mutation to perform. /// - publishResultToStore: If `true`, this will publish the result returned from the operation to the cache store. Default is `true`. + /// - contextIdentifier: [optional] A unique identifier for this request, to help with deduping cache hits for watchers. Should default to `nil`. /// - context: [optional] A context that is being passed through the request chain. Should default to `nil`. /// - queue: A dispatch queue on which the result handler will be called. Should default to the main queue. /// - resultHandler: An optional closure that is called when mutation results are available or when an error occurs. /// - Returns: An object that can be used to cancel an in progress mutation. func perform(mutation: Mutation, publishResultToStore: Bool, + contextIdentifier: UUID?, context: RequestContext?, queue: DispatchQueue, resultHandler: GraphQLResultHandler?) -> Cancellable