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

improve HTTPNetworkTransportRetryDelegate to enable returning custom error #1128

Merged
merged 7 commits into from
Apr 12, 2020
Merged

Conversation

RolandasRazma
Copy link
Contributor

solves use case described in #1121 where delegate might want to return different error depending on logic

…dError:for:,response:retryHandler:) to enable returning custom error
@RolandasRazma RolandasRazma changed the title improove HTTPNetworkTransportRetryDelegate to enable returning custom error improve HTTPNetworkTransportRetryDelegate to enable returning custom error Apr 7, 2020
Copy link
Contributor

@designatednerd designatednerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a test validating that your feature request is working the way you think it should - that is, on a retry, you get the correct error?

@@ -59,11 +59,52 @@ public protocol HTTPNetworkTransportRetryDelegate: HTTPNetworkTransportDelegate
/// - request: The URLRequest which generated the error
/// - response: [Optional] Any response received when the error was generated
/// - retryHandler: A closure indicating whether the operation should be retried. Asyncrhonous to allow for re-authentication or other async operations to complete.
@available(*, deprecated, message: "Use networkTransport(_:receivedError:for:,response:continueHandler:) instead")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is going to be a bit of a mess because even if we deprecate this method, people are still going to have the deprecation warning on the default implementation below.

I'm wondering if this might be a "Let's take advantage of the fact that we're not at 1.0" moment to just straight up replace this method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, I don't see deprecation warning unless I implement method in my delegate. Or I'm missing something?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm...in theory this should still cause a deprecation warning where it's in the same file but maybe that's been disabled to prevent exactly this scenario...

Sources/Apollo/HTTPNetworkTransport.swift Outdated Show resolved Hide resolved
@RolandasRazma
Copy link
Contributor Author

Can you please add a test validating that your feature request is working the way you think it should - that is, on a retry, you get the correct error?

added test. Not rly in style you doing, so let me know if you want me to change it

Copy link
Contributor

@designatednerd designatednerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for not getting back to you on this sooner, I was a bit under the weather. Starting to shape up!

Tests/ApolloTests/HTTPTransportTests.swift Outdated Show resolved Hide resolved
Copy link
Contributor

@designatednerd designatednerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Smashing! Thanks so much for your hard work on this.

@designatednerd designatednerd merged commit 6baac06 into apollographql:master Apr 12, 2020
@designatednerd designatednerd added this to the Next Release milestone Apr 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants