-
Notifications
You must be signed in to change notification settings - Fork 743
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
Update how requests are created so custom subclasses of HTTP requests can be used #1405
Update how requests are created so custom subclasses of HTTP requests can be used #1405
Conversation
…on of custom subclasses of `HTTPRequest`.
…lace that acutally uses it and it can now be subclassed.
import XCTest | ||
import Apollo | ||
|
||
class MultipartFormDataTests: XCTestCase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved this out of the request creator tests to disambiguate what's actually being tested here
@@ -27,40 +27,4 @@ struct TestCustomRequestCreator: RequestCreator { | |||
|
|||
return body | |||
} | |||
|
|||
public func requestMultipartFormData<Operation: GraphQLOperation>(for operation: Operation, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is no longer a requirement of the RequestBodyCreator
protocol, so it's been removed
@@ -198,6 +199,225 @@ class UploadTests: XCTestCase { | |||
} | |||
|
|||
self.wait(for: [expectation], timeout: 10) | |||
} | |||
|
|||
// MARK: - UploadRequest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests were moved over from the RequestCreator
tests since they no longer have anything to do with the request creator
These are slightly larger changes than I'd normally like to make at the RC stage, but I've been itching to get rid of the request creator and this gave me an opening to get rid of its most convoluted bits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
In this PR:
RequestChainNetworkTransport
subclassable and changed two methods to be open so they can be subclassed in order to facilitate using subclasses ofHTTPRequest
when needed. (thanks for the suggestion, Networking Beta: Convenience constructors for HTTPRequest and JSONRequest #1404)UploadRequest
, which meant:UploadRequest
is nowopen
so it can be subclassed.UploadRequest
instead ofRequestCreator
, and non-default creation should be moved from an implementation ofRequestCreator
to a subclass ofUploadRequest
.RequestCreator
protocol has now been renamedRequestBodyCreator
, since it only creates the request body and not a fullHTTPRequest
(which didn't exist in the old networking stack, so the name made more sense then). Associated implementations and property names have been changed accordingly.RequestBodyCreator
protocol.