graphene-django-cud icon indicating copy to clipboard operation
graphene-django-cud copied to clipboard

feat: Ensure that before_save always occurs before a save

Open keithhackbarth opened this issue 3 years ago • 2 comments
trafficstars

We've noticed that in some of the mutations, the before_save trigger actually happens after save. This PR request has a proposed refactor:

Changes:

  • Ensure that the before_save function always takes place before save.
  • Refactor the code so that the before_save function takes a consistent set of parameters (currently it sometimes takes a query set and sometimes an object) and always returns a consistent value (the object that will be created, updated, or deleted). Note: this is a backward-incompatible change but was needed to achieve our implementation of the first item.

Still to-do:

  • Write tests that ensure before_save happens before.

keithhackbarth avatar Jan 05 '22 00:01 keithhackbarth

@tOgg1 - Curious about your feedback on this one or if you think there's a better approach?

keithhackbarth avatar Jan 05 '22 00:01 keithhackbarth

Hi @keithhackbarth!

Thanks!

I'll get on checking this before the end of the week.

tOgg1 avatar Jan 27 '22 09:01 tOgg1

Closing this until the issues are resolved.

tOgg1 avatar Jun 17 '23 07:06 tOgg1