Skip to content

Commit

Permalink
Fix a leak related to use of function used in a closure (apollographq…
Browse files Browse the repository at this point in the history
  • Loading branch information
prabhuamol authored and gh-action-runner committed Aug 8, 2024
1 parent 2ab4500 commit 7d0c7e9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Sources/Apollo/ApolloStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,12 @@ public class ApolloStore {

public class ReadTransaction {
fileprivate let cache: any NormalizedCache

fileprivate lazy var loader: DataLoader<CacheKey, Record> = DataLoader { [weak self] batchLoad in
guard let self else { return [:] }
return try cache.loadRecords(forKeys: batchLoad)

This comment has been minimized.

Copy link
@Kireyin

Kireyin Sep 13, 2024

This is introducing a breaking change and a compilation error - Apollo/Sources/Apollo/ApolloStore.swift:208:22: error: reference to property 'cache' in closure requires explicit use of 'self' to make capture semantics explicit

Should be:

return try self.cache.loadRecords(forKeys: batchLoad)


when compiling with Xcode 14.1

}

fileprivate lazy var loader: DataLoader<CacheKey, Record> = DataLoader(self.cache.loadRecords)
fileprivate lazy var executor = GraphQLExecutor(
executionSource: CacheDataExecutionSource(transaction: self)
)
Expand Down

0 comments on commit 7d0c7e9

Please sign in to comment.