apollographql/apollo-ios

Access to URLSessionDelegate, URLSessionDataDelegate & URLSessionTaskDelegate for Pulse logger usage

Closed this issue · 3 comments

Question

Hi,

I would like to know if it's possible to access the URLSessionDelegate, URLSessionDataDelegate & URLSessionTaskDelegate so we can respond to these delegate methods when needed. We're building an MVP on our current app using GraphQL instead of Rest. In our current setup we use the Pulse logger https://github.com/kean/Pulse for logging network requests in our app and we would like to re-use it for GraphQL calls too.

Thx!

Hi @TripwireNL - it's tricky because URLSessionClient needs to handle those delegate calls. Some of them have no implementation but many are important for NetworkFetchInterceptor to function correctly.

However, since URLSessionClient is an open class you could subclass it and override those delegate methods. You'll need to ensure you're calling the super implementation so that any expected work gets done in response to the delegate call though.

To make this work:

  1. Initialize an instance of DefaultInterceptorProvider using your URLSessionClient subclass.
  2. Use that instance of DefaultInterceptorProvider when you initialize the RequestChainTransportNetwork.

I think with that you should be able to do what you need but let me know if you get stuck.

Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo iOS usage and allow us to serve you better.

@AnthonyMDev - when you're back let's discuss whether this request/behaviour something we should revisit in the work for 2.0.