From 17372ed1722d723355780a7c41cfaa3c992e7089 Mon Sep 17 00:00:00 2001 From: gh-action-runner Date: Thu, 8 Aug 2024 22:35:00 +0000 Subject: [PATCH] Squashed 'apollo-ios/' changes from 104cc94e..2ab4500e 2ab4500e fix: `legacyResponse` property (apollographql/apollo-ios-dev#456) git-subtree-dir: apollo-ios git-subtree-split: 2ab4500ebc61a11a7c5344f1d7a3f4999aea4eab --- Sources/Apollo/HTTPResponse.swift | 11 +++++++---- .../IncrementalJSONResponseParsingInterceptor.swift | 9 +++++---- Sources/Apollo/JSONResponseParsingInterceptor.swift | 3 ++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Sources/Apollo/HTTPResponse.swift b/Sources/Apollo/HTTPResponse.swift index 55d47eeae..2b2cb27f7 100644 --- a/Sources/Apollo/HTTPResponse.swift +++ b/Sources/Apollo/HTTPResponse.swift @@ -19,11 +19,12 @@ public class HTTPResponse { /// [optional] The data as parsed into a `GraphQLResponse` for legacy caching purposes. If you're not using the /// `JSONResponseParsingInterceptor`, you probably shouldn't be using this property. @available(*, deprecated, message: "Do not use. This property will be removed in a future version.") - public var legacyResponse: GraphQLResponse? = nil - + public var legacyResponse: GraphQLResponse? { _legacyResponse } + var _legacyResponse: GraphQLResponse? = nil + /// A set of cache records from the response - var cacheRecords: RecordSet? - + public var cacheRecords: RecordSet? + /// Designated initializer /// /// - Parameters: @@ -49,6 +50,7 @@ extension HTTPResponse: Equatable where Operation.Data: Equatable { lhs.httpResponse == rhs.httpResponse && lhs.rawData == rhs.rawData && lhs.parsedResponse == rhs.parsedResponse && + lhs._legacyResponse == rhs._legacyResponse && lhs.cacheRecords == rhs.cacheRecords } } @@ -60,6 +62,7 @@ extension HTTPResponse: Hashable where Operation.Data: Hashable { hasher.combine(httpResponse) hasher.combine(rawData) hasher.combine(parsedResponse) + hasher.combine(_legacyResponse) hasher.combine(cacheRecords) } } diff --git a/Sources/Apollo/IncrementalJSONResponseParsingInterceptor.swift b/Sources/Apollo/IncrementalJSONResponseParsingInterceptor.swift index 4a16b9d73..219bdbde7 100644 --- a/Sources/Apollo/IncrementalJSONResponseParsingInterceptor.swift +++ b/Sources/Apollo/IncrementalJSONResponseParsingInterceptor.swift @@ -101,14 +101,15 @@ public struct IncrementalJSONResponseParsingInterceptor: ApolloInterceptor { } } + createdResponse._legacyResponse = nil + parsedResult = currentResult parsedCacheRecords = currentCacheRecords } else { - let graphQLResponse = GraphQLResponse( - operation: request.operation, - body: body - ) + let graphQLResponse = GraphQLResponse(operation: request.operation, body: body) + createdResponse._legacyResponse = graphQLResponse + let (result, cacheRecords) = try graphQLResponse.parseResult(withCachePolicy: request.cachePolicy) parsedResult = result diff --git a/Sources/Apollo/JSONResponseParsingInterceptor.swift b/Sources/Apollo/JSONResponseParsingInterceptor.swift index 46f774a4d..16c8fc31b 100644 --- a/Sources/Apollo/JSONResponseParsingInterceptor.swift +++ b/Sources/Apollo/JSONResponseParsingInterceptor.swift @@ -57,8 +57,9 @@ public struct JSONResponseParsingInterceptor: ApolloInterceptor { } let graphQLResponse = GraphQLResponse(operation: request.operation, body: body) + createdResponse._legacyResponse = graphQLResponse + let (result, cacheRecords) = try graphQLResponse.parseResult(withCachePolicy: request.cachePolicy) - createdResponse.parsedResponse = result createdResponse.cacheRecords = cacheRecords