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

Added correct way of default parameters #804

Conversation

kimdv
Copy link
Contributor

@kimdv kimdv commented Oct 2, 2019

How I missed that I don't know..

Because the HTTPNetworkTransport didn't use manualBoundary it will use de protocol extension and not the requestCreator that is provided and implements the method.

I think this is the best way to implement "default" parameters

@kimdv
Copy link
Contributor Author

kimdv commented Oct 2, 2019

Should I see if I can come up with some tests to test it works well?

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.

@kimdv Yes tests would be awesome on this. Thanks!

Sources/Apollo/RequestCreator.swift Outdated Show resolved Hide resolved
@kimdv
Copy link
Contributor Author

kimdv commented Oct 2, 2019

@designatednerd added some tests. Don't know if it is enough?
It is actually just to test if the correct implementation is used.

Also changed name of test file to be more explicit as it also tests custom and requestBody now,

Let me hear what you think 🚀

@@ -90,7 +90,7 @@ class GETTransformerTests: XCTestCase {

func testEncodingQueryWithNullDefaultParameter() {
let operation = HeroNameQuery()
let body = requestCreator.requestBody(for: operation)
let body = requestCreator.requestBody(for: operation, sendOperationIdentifiers: false)
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably worth adding one test to this file where sendOperationIdentifers is true just to make sure that's actually including the operation identifier

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, the default implementation here was actually false.
Maybe that is for another PR?
I can open an issue to you can track it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just not to add something that is not related to this PR and RequestCreator? 😁

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I'll add it in a follow-up PR - you don't need to open an issue for it, I'll leave this comment open


let data = try customRequestCreator.requestMultipartFormData(
for: HeroNameQuery(),
files: [alphaFile!],
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably worth guard let ing this on creation, since a force-unwrap failing in a test causes the whole test suite to crash rather than failing the single test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just copy/paste from other code made by you 🙈
Should I remove all force unwrap in this class?

Copy link
Contributor

Choose a reason for hiding this comment

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

🤦‍♀️Nah I'll fix it in a follow-up PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sowwy 🙈

Copy link
Contributor

Choose a reason for hiding this comment

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

Haha, I'm the moron who did it first, no worries

Tests/ApolloTests/RequestCreatorTests.swift Outdated Show resolved Hide resolved
Tests/ApolloTests/RequestCreatorTests.swift Outdated Show resolved Hide resolved
Tests/ApolloTests/RequestCreatorTests.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.

LGTM pending CI. I'll do a follow up-PR once this is merged to do some test cleanup

@kimdv
Copy link
Contributor Author

kimdv commented Oct 2, 2019

Ping me if you need help with clean up 😁

@designatednerd
Copy link
Contributor

@kimdv Tests seem to have bombed out on MacOS - can you double check that the files are added to the proper targets?

@kimdv
Copy link
Contributor Author

kimdv commented Oct 3, 2019

@designatednerd struct was fileprivate 🤦‍♂️

/// - Parameters:
/// - string: The string to append
/// - name: The name of the part to pass along to the server
public func appendPart(string: String, name: String) throws {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@designatednerd this was only internal. The TestCustomRequestCreator used it and I know I use in my project too.
https://github.com/apollographql/apollo-ios/pull/804/files#diff-b1b6d9ae6149908bf9768bbc4bc4b3b0R50

@kimdv
Copy link
Contributor Author

kimdv commented Oct 3, 2019

Wow. I saw the comment that the there is a weird order. But it took some time to find out why!
But solved the flaky test. It should pass now 🧙‍♂️ (Gandalf emoji)

@designatednerd
Copy link
Contributor

Still approved! :shipit:

@designatednerd designatednerd merged commit 0888dd2 into apollographql:master Oct 3, 2019
@designatednerd designatednerd added this to the 0.16.1 milestone Oct 3, 2019
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