-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
Built in create mutation has regressed and is not able to create model instances correctly #500
Comments
Hey @Mapiarz , Hrm, that change was done on #394 to ensure proxy-model compatibility. Taking a quick look at this I would say that it indeed should either require you to annotate it with Do you know what piece of code exactly made this work so we can try to find a way to make this work again, without breaking proxy-model compatibility? cc @sdobbelaere |
The main change is the usage of objects.create() rather than setting an instance and then saving it. @Mapiarz If you're in a shell, how would you create Booking instance? |
I have detected a regression where the built in
create
mutation is not able to properly process the input and create a django model with a foreign key relation. Consider the example:This used to work in the past but has been broken with 170c27c. Django now returns
ValueError: Cannot assign "UUID('dafceb8a-2f28-4be8-b73a-b196a77126f4')": "Booking.boat" must be a "Boat" instance.
The input is not processed before calling the manager
create
method. The input is correctly processed when creating the dummy instance for form cleaning OR when using the built inupdate
mutation. The update and create mutations have diverged significantly and cause unexpected behavior. And btw, the argument that the managercreate
method must be used can be extended to managerupdate
method as well, so that's another inconsistency that has been introduced.For the time being, I can work around the problem by annotating the input with
strawberry.ID
instead ofuuid.UUID
. But that's not good overall as I now have discrepancy between typing in my create vs update mutations, I lose the strong UUID typing in the schema and validation (so it will also accept an int or any string for that matter) and I have to deal with a string instead of a properUUID
object instance.Upvote & Fund
The text was updated successfully, but these errors were encountered: