mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-07-02 03:13:13 +03:00
return back instance fields so as not to overwrite not required fields on None
This commit is contained in:
parent
558288afce
commit
be9cffab99
|
@ -186,6 +186,18 @@ class DjangoModelFormMutation(BaseDjangoFormMutation):
|
||||||
kwargs = {cls._meta.return_field_name: obj}
|
kwargs = {cls._meta.return_field_name: obj}
|
||||||
return cls(errors=[], **kwargs)
|
return cls(errors=[], **kwargs)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_form_kwargs(cls, root, info, **input):
|
||||||
|
kwargs = super().get_form_kwargs(root, info, **input)
|
||||||
|
instance = kwargs.get('instance')
|
||||||
|
if not instance:
|
||||||
|
return kwargs
|
||||||
|
|
||||||
|
for field in kwargs.get('instance')._meta.fields:
|
||||||
|
if field.name not in kwargs['data'] and field.name != 'id':
|
||||||
|
kwargs['data'][field.name] = getattr(instance, field.name)
|
||||||
|
return kwargs
|
||||||
|
|
||||||
|
|
||||||
def _set_errors_flag_to_context(info):
|
def _set_errors_flag_to_context(info):
|
||||||
# This is not ideal but necessary to keep the response errors empty
|
# This is not ideal but necessary to keep the response errors empty
|
||||||
|
|
Loading…
Reference in New Issue
Block a user