Signals
The library fires custom Django signals at the end of CUD mutation execution. These are useful when you want to react to mutation-level events rather than raw model post_save/post_delete events.
Available signals
The following signals are available from graphene_django_cud.signals:
post_create_mutationpost_update_mutationpost_delete_mutationpost_batch_create_mutationpost_batch_update_mutationpost_batch_delete_mutationpost_filter_update_mutationpost_filter_delete_mutation
Example
from graphene_django_cud.signals import post_create_mutation
@post_create_mutation.connect
def handle_post_create_mutation(sender, instance, **kwargs):
print(f"A new instance was created by {sender}: {instance}")
Signal arguments
post_create_mutationsenderThe mutation class.
instanceThe instance that was created.
post_update_mutationsenderThe mutation class.
instanceThe instance that was updated.
post_delete_mutationsenderThe mutation class.
idThe id returned by the mutation. This may be a Relay global id when Relay is used, and can be customized by overriding
get_return_id.raw_idThe raw database id of the deleted instance.
deleted_input_idThe id value supplied to the delete mutation.
post_batch_create_mutationsenderThe mutation class.
instancesThe instances that were created.
post_batch_update_mutationsenderThe mutation class.
instancesThe instances that were updated.
post_batch_delete_mutationsenderThe mutation class.
idsThe input ids supplied to the mutation.
deletion_countThe number of instances that were deleted.
deleted_idsThe ids returned by the mutation. These can be customized by overriding
get_return_id.
post_filter_update_mutationsenderThe mutation class.
instancesA queryset of the instances that were updated.
post_filter_delete_mutationsenderThe mutation class.
idsThe ids of the instances that were deleted.