exclusive-coralE
Refine3y ago
9 replies
exclusive-coral

Update related objects

Hi there,

I’m looking for a way to update nested objects using Refine. Did not yet settle on a data provider but initially thought about using Hasura (GraphQL) on top of postgres. It allowed me to easily query multiple nested related objects and using the Ant Design system I worked out to load the nested objects in an edit form using <Form.List>.

Usecase
I'd like to make a page to create and edit invoices, in which the underlying tasks can be edited within the same form. Using the AntD I was able to create a working frontend (see attachment), but can't yet handle the mutation / creation in the database.

The frontend allows me to remove and add tasks, which returns the correct values.
Below you can see the console.log(values) caught in the onFinish

Task 1 and Task 2 were loaded from the db. Task 3 was added in the frontend:

{ customer_id: 1, invoice_text: "Invoice text example", tasks: [ { name: "Task 1 name", description: "Description of task 1" }, { name: "Task 2 name", description: "Description of task 2" }, { name: "Task 3 name", description: "Description of task 3 etc. etc." } ] }


However, it turns out Hasura does not yet allow nested mutations since it’s still on their roadmap:
https://github.com/hasura/graphql-engine/issues/1573

I was therefor wondering whether another Data Provider would be able to handle these type of mutations?

And if not, would it be possible to handle the mutations/creations of the tasks tasks separately? Any pointers on this?

Thanks in advance!
Thomas
nested_objects.png
GitHub
First, thank you very much for your work on Hasura, its a great product. There is a feature that I would be very happy to have, wanted to know what are your thoughts on it. Currently there Is a nes...
update nested object · Issue #1573 · hasura/graphql-engine
Was this page helpful?