Skip to content

Added correct way of default parameters#804

Merged
designatednerd merged 9 commits intoapollographql:masterfrom
kimdv:kimdv/change-default-parameter-in-request-creator
Oct 3, 2019
Merged

Added correct way of default parameters#804
designatednerd merged 9 commits intoapollographql:masterfrom
kimdv:kimdv/change-default-parameter-in-request-creator

Conversation

@kimdv
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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!

Comment thread Sources/Apollo/RequestCreator.swift Outdated
Comment thread Sources/Apollo/RequestCreator.swift Outdated
@kimdv
Copy link
Copy Markdown
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 🚀

func testEncodingQueryWithNullDefaultParameter() {
let operation = HeroNameQuery()
let body = requestCreator.requestBody(for: operation)
let body = requestCreator.requestBody(for: operation, sendOperationIdentifiers: false)
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

Comment thread Tests/ApolloTests/RequestCreatorTests.swift Outdated
Comment thread Tests/ApolloTests/RequestCreatorTests.swift Outdated
Comment thread Tests/ApolloTests/RequestCreatorTests.swift Outdated
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

kimdv commented Oct 2, 2019

Ping me if you need help with clean up 😁

@designatednerd
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 kimdv requested a review from designatednerd October 3, 2019 09:28
@kimdv
Copy link
Copy Markdown
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
Copy Markdown
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