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

feat(apollo-ios-codegen): Stable sort schema types for SchemaMetadata #514

Merged

Conversation

asmundg
Copy link
Contributor

@asmundg asmundg commented Oct 18, 2024

In some cases, the order of parsed types come out differently on different systems (unclear why). This creates problems in some situations where we're checking in the generated SchemaMetadata files, as we continuously flip back and forth between two orderings, generating git diffs.

By sorting the parsed types, we guarantee that their order is stable and no unnecessary diffs are introduced.

In some cases, the order of parsed types come out differently on
different systems (unclear why). This creates problems in some
situations where we're checking in the generated SchemaMetadata files,
as we continuously flip back and forth between two orderings, generating
git diffs.

By sorting the parsed types, we guarantee that their order is stable and
no unnecessary diffs are introduced.
Copy link

netlify bot commented Oct 18, 2024

👷 Deploy request for eclectic-pie-88a2ba pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 524d6ed

@svc-apollo-docs
Copy link
Collaborator

svc-apollo-docs commented Oct 18, 2024

✅ Docs Preview Ready

No new or changed pages found.

Copy link

netlify bot commented Oct 18, 2024

👷 Deploy request for apollo-ios-docc pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 524d6ed

@asmundg
Copy link
Contributor Author

asmundg commented Oct 18, 2024

I'm not sure what's going on here, and I'm struggling to produce a minimal repo. But I have two machines that consistently produce a different ordering of the types in the schema loaded by the frontend (compilationResult.referencedTypes) in IRBuilder.

@BobaFetters
Copy link
Member

I'm surprised this issue hasn't been raised before, can you provide more info about the 2 machines where you see the differences? Such as processor type, os versions, maybe xcode versions between the machines etc? Would be useful to help understand the underlying cause of the issue.

I'm not opposed to having this be sorted though, would make that file more readable, not sure if there are any potential complications of this you can think of @AnthonyMDev ? I supposed this would cause a change for diff purposes for all users the first time they ran it.

@AnthonyMDev
Copy link
Contributor

Yeah, it's very odd that this is happening, but I'm not opposed to sorting the types before generation. Yes, there will be a diff for existing users, but it won't be a breaking change.

@asmundg
Copy link
Contributor Author

asmundg commented Oct 18, 2024

I'm surprised this issue hasn't been raised before, can you provide more info about the 2 machines where you see the differences? Such as processor type, os versions, maybe xcode versions between the machines etc? Would be useful to help understand the underlying cause of the issue.

Unclear, I mainly observed a diff between my Macbook and our internal CI system where I don't have full clarity on the environment. But I found some other devs with slightly different hardware that get the alternate type order. I can see if I can do a more thorough comparison between the systems.

Copy link
Member

@BobaFetters BobaFetters left a comment

Choose a reason for hiding this comment

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

I think this looks good, thanks for the contribution!

@BobaFetters BobaFetters merged commit 7eaf41e into apollographql:main Oct 21, 2024
27 checks passed
BobaFetters pushed a commit that referenced this pull request Oct 21, 2024
378929ba feat(apollo-ios-codegen): Stable sort schema types for SchemaMetadata (#514)

git-subtree-dir: apollo-ios-codegen
git-subtree-split: 378929baa366b1e607fe70fb61834be036432312
BobaFetters pushed a commit that referenced this pull request Oct 21, 2024
…e sort schema types for SchemaMetadata

git-subtree-dir: apollo-ios-codegen
git-subtree-mainline: d336f36
git-subtree-split: 378929baa366b1e607fe70fb61834be036432312
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.

4 participants