.. _djangopatchmutation: ================================ DjangoPatchMutation ================================ Will update an existing instance of a model. The PatchMutation (in contrast to the UpdateMutation) does not require all fields to be supplied. I.e. all are fields are optional. Mutation input arguments: +------------+-----------+ | Argument | Type | +============+===========+ | id | ID! | +------------+-----------+ | input | Object! | +------------+-----------+ All meta arguments: +--------------------------+------------+-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Argument | type | Default | Description | +==========================+============+===========+===================================================================================================================================================================================+ | model | Model | None | The model. **Required**. | +--------------------------+------------+-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | only\_fields | Iterable | None | If supplied, only these fields will be added as input variables for the model | +--------------------------+------------+-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | exclude\_fields | Iterable | None | If supplied, these fields will be excluded as input variables for the model. | +--------------------------+------------+-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | return\_field\_name | String | None | The name of the return field within the mutation. The default is the camelCased name of the model | +--------------------------+------------+-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | permissions | Tuple | None | The permissions required to access the mutation | +--------------------------+------------+-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | login\_required | Boolean | None | If true, the calling user has to be authenticated | +--------------------------+------------+-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | auto\_context\_fields | Dict | None | A mapping of context values into model fields. See below | +--------------------------+------------+-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | optional\_fields | Tuple | () | A list of fields which explicitly should have ``required=False`` | +--------------------------+------------+-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | required\_fields | Tuple | None | A list of fields which explicitly should have ``required=True`` | +--------------------------+------------+-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | custom\_fields | Tuple | None | A list of custom graphene fields which will be added to the model input type. | +--------------------------+------------+-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | type\_name | String | None | If supplied, the input variable in the mutation will have its typename set to this string. This is useful when creating multiple mutations of the same type for a single model. | +--------------------------+------------+-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | many\_to\_many\_extras | Dict | {} | A dict with extra information regarding many-to-many fields. See below. | +--------------------------+------------+-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | many\_to\_one\_extras | Dict | {} | A dict with extra information regarding many-to-one relations. See below. | +--------------------------+------------+-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | foreign\_key\_extras | Dict | {} | A dict with extra information regarding foreign key extras. | +--------------------------+------------+-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | one\_to\_one\_extras | Dict | {} | A dict with extra information regarding one to one extras. | +--------------------------+------------+-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | use_select_for_update | Boolean | True | If true, the queryset will be altered with ``select_for_update``, locking the database rows in question. Used to ensure data integrity on updates. | +--------------------------+------------+-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ Example mutation ^^^^^^^^^^^^^^^^ .. code:: mutation { updateUser(id: "VXNlck5vZGU6MQ==", input: { name: "John Doe", }){ user{ id name address } } }