-
Notifications
You must be signed in to change notification settings - Fork 470
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
Add tests for "swift: Fix --operationIdsPath option" #1431 #2017
Add tests for "swift: Fix --operationIdsPath option" #1431 #2017
Conversation
Generated file includes fragments now (fixes apollographql#1430)
df117bc
to
a131cc1
Compare
a131cc1
to
2e5338a
Compare
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 reasonable to me but would love a look from @JakeDawkins, who actually knows how javascript works, unlike me 😆
@@ -267,7 +267,7 @@ export class SwiftAPIGenerator extends SwiftGenerator<CompilerContext> { | |||
); | |||
fragmentsReferenced.forEach(fragmentName => { | |||
this.print( | |||
swift`.appending(${this.helpers.structNameForFragmentName( | |||
swift`.appending("\\n" + ${this.helpers.structNameForFragmentName( |
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.
@designatednerd Sorry for the additional commit after receiving LGTM.
I just found that the current generated code for Swift doesn't have a newline between query and fragment.
Because of missing newlines, the generated operation ID and sent query's sha256 hash always differs.
After this change, operation ID and sha256 will be same so we can treat Persisted Query more easily.
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.
The current implementation outputs the following query document as source
property of operationIds.json
.
sha256 hash calculated from this source is put into the same operationIds.json
.
query SomeQuery {
...SomeFragment
}
fragment SomeFragment {
id
}
However, Apollo iOS sends the following query document (missing newlines).
sha256 hash is calculated from this source at runtime so there's difference between 2 hashes.
query SomeQuery {
...SomeFragment
}fragment SomeFragment {
id
}
This commit fixes this problem with appending missing newlines.
@JakeDawkins Could you take a look at this one when you have time? |
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.
@manicmaniac this looks good to me! Thanks for your patience here! :)
I took over the rest tasks (adding tests) of #1431.
Could you make sure that it is enough?
master
branchnode node_modules/.bin/jest -t generate -i --no-cache
to exclude unchanged.TODO:
*Make sure changelog entries note which project(s) has been affected. See older entries for examples on what this looks like.