Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some proposals for improvement #119

Open
zaunerp opened this issue Nov 1, 2023 · 1 comment
Open

Some proposals for improvement #119

zaunerp opened this issue Nov 1, 2023 · 1 comment

Comments

@zaunerp
Copy link

zaunerp commented Nov 1, 2023

Hello,

first of all the graphene-django-cud is a wonderfull tool and simplifys a lot of things, but I found some issues for some cases.

One rather minor things that I spotted was, if I add foreign_key_extras they are always required. In my used case I have foreinkeys that are optional, but if I put them in optional fields they don't get ignored and I get an error message that one of my fields don't have items. Makes sense because it's expecting the foreignkey to be in the query. You can workaround this by just adding an empty dict with the foreign key.

Next Point is, Foreingkeys that get objects not ids but are get_or_create objects. E.g. Numberplates of cars. I have some plates pre saved, but I cannot save all numberplates that are out there and I have some number plates presaved that I use for driveaways. So if someone adds a car, with the number plate i have already saved use this one, if the number plate not in the database make a new one and use it.

My suggestion to solve a problem like this, would be that if you add foreign_key_extras with the type e.g. CreateNumberPlateInput the hooks (before_mutate, before_save, after_mutate) in the class CreateNumberPlateMutation still gets called even if it's only in a foreign_key_extras of another class. Also enable the possiblity to overwrite the whole mutate function that is called from the CreateMutation class.

I think this would lift this tool to a new level of utilization. E.g my case with get_or_create can be covered because I can add a before_save method and overwrite the object if the object exists.

best regards,

Patrick

@zaunerp zaunerp changed the title Some proposals for improvment Some proposals for improvement Nov 7, 2023
@tOgg1
Copy link
Owner

tOgg1 commented Feb 27, 2024

Thanks for the feedback @zaunerp. I'll look into some of these.

Also enable the possiblity to overwrite the whole mutate function that is called from the CreateMutation class.

Overriding mutate functions is possible as described here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants