Convert the JSON output of an introspection query into a deterministic ordering of types (sorted by name). This results in saner diffs when committing schemas to version control.
Can convert the output of introspection queries in JSON format to a sorted, deterministic ordering of types. See the test fixtures.
AbsintheSortingCodec.encode!(Jason.decode!("swapi.json"))
Can be used to convert an Absinthe schema to a deterministic format by using AbsintheSortingCodec as the JSON encoder.
mix absinthe.schema.json --schema MySchema --json-codec AbsintheSortingCodec --pretty
NOTE: If the mix command gives the following error --
(Argument Error) you atttempted to apply :module on "AbsintheSortingCodec". If you are using apply/3, make sure the module is an atom. If you are using the dot syntax, such as map.field or module.function, make sure the left side of the dot is an atom or a map
-- you need to upgrade to Absinthe 1.4.14 or 1.5 or later.
If available in Hex, the package can be installed
by adding absinthe_sorting_codec
to your list of dependencies in mix.exs
:
def deps do
[
{:absinthe_sorting_codec, "~> 1.0.1"}
]
end
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/absinthe_sorting_codec.
Thanks to Maarten van Vliet for developing Absinthe SDL, which this project is patterned after.