The schema.json is not stable at the moment. Even if I order the object keys in the json file, it's not stable with the same schema. This means that arrays are not generated in the same order. Would be nice to have this for git checkins and docker cache busting.
Yeah that's an understandably annoying problem. Fundamentally it comes down to the JSON library though since that's really where the order is lost, which is of course perfectly legal from the JSON spec.
Hi @benwilson512, that's what I thought at first as well, but the list order is not the same for the same schema (and lists are ordered in JSON).
Reproduce by:
cat schema.json | jq --sort-keys > schema-ordered.json
If you do that for two generated schema.json files and diff them they are not the same.
I think it will be resolved by sorting the list of types (by for instance type name)
Would this lib be useful to you?
Ah great! Seems like somebody had the exact same problem, and solved it with a custom encoder. Thanks!
This worked great. @benwilson512: You might want to consider adopting these few lines of code to stabilize the lists in the &Absinthe.Schema.introspect/1 function (or further down in the internals). This also makes the data structure stable. So introspected_schema_invocation_1 == introspected_query_invocation_2.
This is great @benwilson512 !!
Thanks a lot for the work!
Can't wait for #769 馃
Most helpful comment
Ah great! Seems like somebody had the exact same problem, and solved it with a custom encoder. Thanks!