-
Notifications
You must be signed in to change notification settings - Fork 730
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
Passing Operations through HTTPNetworkTransportDelegate #1189
Comments
Hey @Kalvin126 - it's a bit of a hack, but you can grab the JSON out of the I'm in the middle of experimenting with a more interceptor-based system that will allow use cases like this a LOT more easily. I don't have an ETA but I think for now the workaround is probably preferable to adding another delegate method, particularly since there's somewhat limited need for accessing the operation at the point of adding headers. Will leave this open to make sure I flag you when the network stuff is up. |
btw, there is an other example: |
Yes, a more interceptor-based system will allow passing more context and replace this delegate method. |
Hey, we recently added operation to
Also extended |
@Kalvin126 Please check out the RFC for networking changes in #1340 - that should help (and also includes a |
Hi, our new networking stack will be shipping as beta shortly and the ability to see the operation and request will be in there with it. I did change the retry count to be part of one of the interceptors after my previous comment. Please see #1341 for the details. |
The networking stack is now available as a beta at |
Hey Apollo Community! I'd like to post a feature request.
Use Case:
I would like to add headers to a
URLRequest
conditionally based on the Operation being committed.Analysis:
I see that
HTTPNetworkTransportPreflightDelegate
has a functionfunc networkTransport(_ networkTransport: HTTPNetworkTransport, willSend request: inout URLRequest)
. This is where it is intended to modify theURLRequest
before it is actually sent out. However, there is no way to get theGraphQLOperation
that is being committed. That delegate call is called inHTTPNetworkTransport
's function:So a copy of the
GraphQLOperation
is held here. I was thinking that we could pass the operation with the delegate calls but the existence of an associated type inGraphQLOperation
does not allow that.The only way around that would be to move out the
Data
associated type, but that would break a bunch of other code and would require re-architecting. Another issue did talk about placing a context object. That could be a required member ofGraphQLOperation
that is then pass then passed to delegate instead of the Operation itself. I'd be interested in hearing the community's thoughts on this.The text was updated successfully, but these errors were encountered: