Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access to URLSessionDelegate, URLSessionDataDelegate & URLSessionTaskDelegate for Pulse logger usage #3471

Closed
TripwireNL opened this issue Nov 19, 2024 · 3 comments
Labels
question Issues that have a question which should be addressed

Comments

@TripwireNL
Copy link

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!

@TripwireNL TripwireNL added the question Issues that have a question which should be addressed label Nov 19, 2024
@TripwireNL TripwireNL changed the title Access to URLSessionDelegate, URLSessionDataDelegate & URLSessionTaskDelegate Access to URLSessionDelegate, URLSessionDataDelegate & URLSessionTaskDelegate for Pulse logger usage Nov 19, 2024
@calvincestari
Copy link
Member

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.

@calvincestari calvincestari closed this as not planned Won't fix, can't repro, duplicate, stale Nov 19, 2024
Copy link
Contributor

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.

@calvincestari
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Issues that have a question which should be addressed
Projects
None yet
Development

No branches or pull requests

2 participants