other-emerald•7h ago
Update two endpoints
what are the options if i want my form to update two endpoints with its data at the end? e.g. /belege and /belegepositionen ?
2 Replies
Hi @zomh. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
If you want your form in refine to update two different endpoints (e.g.,
You can use a custom form submission handler where, on submit, you manually trigger two mutations (e.g., using
If you want to update multiple records of the same resource, you can use
You could implement custom logic in your data provider to handle a "composite" update, but this is not described in the documentation and would require you to design your own API and data provider method. Summary:
There is no built-in refine feature to update two different endpoints from a single form submission. The recommended approach is to handle this in your form's submit handler by calling the appropriate hooks for each endpoint sequentially or in parallel, depending on your requirements. If you need to update multiple records of the same resource, use
useUpdateMany Example
Data Fetching and Updating Data
Github Issue: useForm Support For Array of Records (ids) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
/belege
and /belegepositionen
) with its data at the end, the knowledge sources do not describe a built-in way to do this in a single form submission. Refine's useForm
and related hooks (useUpdate
, useCreate
, etc.) are designed to operate on a single resource at a time, and there is no documented support for natively updating multiple resources/endpoints in one go from a single form submission.
However, you have a few options based on the available information:
1. Custom Submission HandlerYou can use a custom form submission handler where, on submit, you manually trigger two mutations (e.g., using
useUpdate
or useCreate
for each endpoint). This means you would call both mutations in your handler, passing the relevant data to each. This approach is not handled automatically by refine's form hooks, but is possible by combining the hooks yourself.
2. useUpdateMany (for batch updates to one resource)If you want to update multiple records of the same resource, you can use
useUpdateMany
. However, this does not apply to updating two different resources/endpoints at once—it is for batch updating multiple records within a single resource only useUpdateMany docs Table Example.
3. Custom Data Provider LogicYou could implement custom logic in your data provider to handle a "composite" update, but this is not described in the documentation and would require you to design your own API and data provider method. Summary:
There is no built-in refine feature to update two different endpoints from a single form submission. The recommended approach is to handle this in your form's submit handler by calling the appropriate hooks for each endpoint sequentially or in parallel, depending on your requirements. If you need to update multiple records of the same resource, use
useUpdateMany
. For two different resources, use two separate hooks in your handler.
If you need more advanced or transactional behavior, you would need to implement this logic yourself, either in your frontend handler or in your backend API.
The knowledge sources do not provide a more integrated solution for this scenario. If you need further guidance on implementing the custom handler, let me know!useUpdateMany Example
Data Fetching and Updating Data
Github Issue: useForm Support For Array of Records (ids) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
<@240974567730970625> Kapa.ai is still learning and improving, please let me know how I did by reacting below.