Skip to content

Commit

Permalink
[gradle-plugin] sort input files (apollographql#5919)
Browse files Browse the repository at this point in the history
* sort input files

* update test fixtures

* add Gradle issue
  • Loading branch information
martinbonnin authored May 27, 2024
1 parent c3c9489 commit 89ee17d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,15 @@ object ApolloCompiler {
* Step 1: parse the documents
*/
val definitions = mutableListOf<GQLDefinition>()
executableFiles.forEach { normalizedFile ->
/**
* Sort the input files.
* The generated Kotlin code does not depend on the order of the inputs but in case we're serializing the
* intermediate usedCoordinates, their order depends on the order of the input files.
*
* See https://github.com/gradle/gradle/issues/29321
* See https://github.com/apollographql/apollo-kotlin/pull/5916
*/
executableFiles.sortedBy { it.normalizedPath }.forEach { normalizedFile ->
val fileDefinitions = normalizedFile.file.definitions()

definitions.addAll(fileDefinitions)
Expand Down
2 changes: 1 addition & 1 deletion tests/integration-tests/testFixtures/manifest.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"format":"apollo-persisted-query-manifest","version":1,"operations":[{"id":"debf75d1c1580dc06d3deb37daaa1439cbc0aeef776e2cb836d2720ca9b2761e","body":"mutation NestedUpload($topFile: Upload, $topFileList: [Upload], $nested: NestedObject) { nestedUpload(topFile: $topFile, topFileList: $topFileList, nested: $nested) }","name":"NestedUpload","type":"mutation"},{"id":"bd822d287b6428f2d9135349edbd3a2997ca9ec8ed433c1b9a078d3cf2f70eae","body":"mutation SingleUploadTwice($file1: Upload!, $file2: Upload!) { file1: singleUpload(file: $file1) { id path filename mimetype } file2: singleUpload(file: $file2) { id path filename mimetype } }","name":"SingleUploadTwice","type":"mutation"},{"id":"7b597dfc22b044880da8ddea282fd3cdc414972fecc42673e01870f2c2a83873","body":"mutation MultipleUpload($files: [Upload!]!) { multipleUpload(files: $files) { id path filename mimetype } }","name":"MultipleUpload","type":"mutation"},{"id":"99c2bd8836d69bb361489392d1bcf2897780c9d5f653b7ab87d6a5c88a3b14fc","body":"mutation SingleUpload($file: Upload!) { singleUpload(file: $file) { id path filename mimetype } }","name":"SingleUpload","type":"mutation"}]}
{"format":"apollo-persisted-query-manifest","version":1,"operations":[{"id":"7b597dfc22b044880da8ddea282fd3cdc414972fecc42673e01870f2c2a83873","body":"mutation MultipleUpload($files: [Upload!]!) { multipleUpload(files: $files) { id path filename mimetype } }","name":"MultipleUpload","type":"mutation"},{"id":"debf75d1c1580dc06d3deb37daaa1439cbc0aeef776e2cb836d2720ca9b2761e","body":"mutation NestedUpload($topFile: Upload, $topFileList: [Upload], $nested: NestedObject) { nestedUpload(topFile: $topFile, topFileList: $topFileList, nested: $nested) }","name":"NestedUpload","type":"mutation"},{"id":"99c2bd8836d69bb361489392d1bcf2897780c9d5f653b7ab87d6a5c88a3b14fc","body":"mutation SingleUpload($file: Upload!) { singleUpload(file: $file) { id path filename mimetype } }","name":"SingleUpload","type":"mutation"},{"id":"bd822d287b6428f2d9135349edbd3a2997ca9ec8ed433c1b9a078d3cf2f70eae","body":"mutation SingleUploadTwice($file1: Upload!, $file2: Upload!) { file1: singleUpload(file: $file1) { id path filename mimetype } file2: singleUpload(file: $file2) { id path filename mimetype } }","name":"SingleUploadTwice","type":"mutation"}]}

0 comments on commit 89ee17d

Please sign in to comment.