awake-maroonA
Refine3y ago
6 replies
awake-maroon

What parameter should I set to make mutate() optionally return the created data?

I would like to create a new resource and navigate to the edit view for that resource.

        mutate(
          {
            resource: "deal",
            values: {
              ...
            },
            // Any parameter here to signal to the data provider that I need the newly created resource?
            },
          },
          {
            onError: (error) => {
               ...
            },
            onSuccess: (data) => {
              // My data provider may return undefined data.data.
              go({
                to: `/resource/${data.data.id}`,
                type: "push",
              });
            },
          }


When I call useCreate's mutate() function, onSuccess could optionally contain the data I need to go() to the edit view.
However, by default my data provider performs the create without a following select. I would like to signal to my data provider to optionally select the created resource.

What is the canonical way to pass this option in Refine?
Was this page helpful?