So I understand the current behaviour and why accumulate did not work in previous Elixir versions.
It seems that you are calling put_definition
many times before you invoke accumulate: true
. If I do this:
if @absinthe_definitions do
raise "omg"
end
Module.register_attribute(__MODULE__, :absinthe_definitions, accumulate: true)
You will see that @absinthe_definitions
is not nil. The behaviour of setting an attribute to accumulate after it is set is âundefinedâ. In previous versions, we were still able of keeping whatever has been accumulated (with caveats) but in the new version we discard it.
However, I would say that the previous behaviour (in earlier Elixir versions) is also broken because your put_definition
would lead to a bunch of duplicated definitions. When accumulate: true
is false, put_definition
works fine, but when it is enabled, you would end-up getting the whole list, prepending to it, and then adding it as an entry on top of the existing list. For example, imagine you had definitions x, y and z already stored. In the attribute, they would be stored as [:z, :y, :x]
. Now imagine that you add :a
, at the end you will end-up with [[:a, :z, :y, :x], :z, :y, :x]
. However, it seems accumulate: true
is only set too late in your suite, so this doesnât happen there.