strawberry-django icon indicating copy to clipboard operation
strawberry-django copied to clipboard

How to override the logic on the Basic create, retrieve, update and delete (CRUD) types and mutations

Open sisocobacho opened this issue 1 year ago • 3 comments

I will like to override the logic inside basic create mutation, much like in django restframework modelviewsets or serializers. What is the best way of doing this?

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar

sisocobacho avatar Aug 10 '22 02:08 sisocobacho

Hi @sisocobacho ,

What exactly are you trying to override?

You can probably override the field to call your own function instead of the ones the current ones call for example. Or you can have a basic mutation and call the create/retrieve/update/delete functions for example.

If you want to give an example of a use case I can suggest something for you

bellini666 avatar Aug 12 '22 13:08 bellini666

Hello, Thanks for the suggestions. Basically what I am trying to do is insert business logic inside those mutation without having to rewrite a new one from 0 and make use off the functionality that those mutations already have. For example doing something before or after saving the model in the create mutation.

sisocobacho avatar Aug 13 '22 05:08 sisocobacho

Yeah hooks are a great idea..

nrbnlulu avatar Aug 13 '22 20:08 nrbnlulu