dataloader
dataloader copied to clipboard
Raise when primary keys in Ecto are nils
In some cases, when we have an Ecto payload, primary key can be set to nil. This can lead to situation where dataloader is associating the incorrect child object to a parent object. (See the issue here: https://github.com/absinthe-graphql/dataloader/issues/172).
This helps to avoid overlooking such situations by raising when nil was found in primary keys.
Alternative solution would be to use
record
|> :erlang.term_to_iovec()
|> :erlang.md5()
when we find nils in primary keys (so the same situation like without primary key at all). Then it should work even without primary keys loaded. But I didn't test it and I don't know if it's better. @benwilson512 wdyt?
Sure, thanks for looking on it, I have pushed the simplified version.
@szymonkozak can you please update the changelog. Please add an Unreleased heading to it and add your change under that. Thanks!
@cschiewek Are we ready for a merge now?