Use weak references to Apollo client in closures#854
Use weak references to Apollo client in closures#854designatednerd merged 1 commit intoapollographql:masterfrom
Conversation
designatednerd
left a comment
There was a problem hiding this comment.
Good call on the closures, got a question on one thing though
|
|
||
| private final class FetchQueryOperation<Query: GraphQLQuery>: AsynchronousOperation, Cancellable { | ||
| let client: ApolloClient | ||
| weak var client: ApolloClient? |
There was a problem hiding this comment.
Why does this need to be weak here?
There was a problem hiding this comment.
I think you're adding the operation to the client's queue
apollo-ios/Sources/Apollo/ApolloClient.swift
Lines 137 to 138 in 509b222
so both the client and the operation will be retained here
There was a problem hiding this comment.
oh woof, good point.
designatednerd
left a comment
There was a problem hiding this comment.
Looks good to me!
|
Anyone else who ends up here wondering why they're not getting any data back anymore... you're probably not holding onto a strong reference of the |
|
Ha, good catch! I'll make a note of it on the release notes for |
This PR changes a few closures that were keeping a strong reference to the Apollo client. This is to make sure that as soon as the user of Apollo client releases its reference, all Apollo operations will stop.