Open danrivett opened 3 years ago
This issue has been bugging me for at least 6 months but I thought it would have bugged Amplify devs more with their running codegen more often than I do, so I just assumed it would be addressed for their sanity's sake if not mine π
I guess it's largely client codebases that would be checking these files into source control etc.
I can also confirm this affects not just GraphQL generated files such as graphql/schema.json
when running amplify codegen
but also DataStore bindings generated from running amplify codegen models
(e.g. index.js
, index.d.ts
etc.).
Again, may sound trivial, but every change I make (such as just now adding in a new Lambda DataSource) causes a lot of reordering of existing elements and it's just too dangerous most of the time to not check them in, in case there are subtle changes made somewhere.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Not sure if there is any update on this ticket. It would be great from an infrastructure-as-code perspective if generated code was generated in a way that removed the noise of unchanged but moved code since it's committed into source control.
I don't know how feasible that is?
I've definitely run into this too, and see the same thing that "aws_api_key"
, "aws_iam"
and "aws_cognito_user_pools"
seem to shuffle around a lot which can be super confusing. I'd be super happy if the sort order could be well defined.
Just as a random example I've used JSON for Modern C++ in another project and it provides the type ordered_json
which is perfect for these kinds of situations (see https://json.nlohmann.me/api/ordered_json/). If Amplify could use a similar mechanism inside whatever JSON library it's using that would be incredibly helpful! π
First of all, I'm surprised I couldn't find an existing bug, so if I've missed it, apologies. But as I couldn't find one I'm creating this ticket as as surely I'm not the only one this drives nuts over time...
Describe the bug Running
amplify push
and regenerating GraphQL code bindings, or simply runningamplify codegen
on a GraphQL schema that hasn't changed results in unnecessary changes to files such asgraphql/schema.json
simply due to reordering of the same output due to apparent non-deterministic ordering in the generated code.Amplify CLI Version 4.35.0
To Reproduce Run the commands listed above a few times and see unnecessary and noisy changes made to files such as
graphql/schema.json
.Expected behavior All code generated should be generated in a consistent deterministic, possibly sorted, order so that:
@aws-amplify/cli
package can cause expected changes to the generated files that are required even if not caused directly by user changes to their GraphQL schema, and so running a codegen after updating the package version without any GraphQL schema changes should be able to show if the version has introduced changes or not; currently that's not clear, it could just be non-deterministic reordering.Screenshots An example diff highlighting one such apparently unnecessary reordering:
Desktop (please complete the following information):
Additional context Git commit history is important to in order to understand when particular bugs may have been introduced and by what changes, and so unnecessary noise in codegen files is more important than it may seem.