dependent-tan
dependent-tan4mo ago

Refine useApply hook function

There are REST Apis which are not CRUD but just ARD which is apply read delete, basically apply instead of create and edit. Mostly kubernetes uses it I want a custom hooks in the data provider for it too. In the future the data provider might need support for watch mode in GET to support event source but its for later. (same idea from the kubernetes api)
3 Replies
kapa.ai
kapa.ai4mo ago
Hi @yairtheyair. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Hmm, I don't know enough to give you a confident answer yet. The knowledge sources provided do not mention a useApply hook or a way to create custom hooks in Refine. However, Refine does provide a variety of data hooks for CRUD operations, such as useOne, useUpdate, useCreate, useDelete, useList, useApiUrl, useCustom, useMany, useCreateMany, useDeleteMany, and useUpdateMany source (https://refine.dev/docs/guides-concepts/data-fetching#data-hooks). For non-CRUD operations, you might be able to use the useCustom hook, which is used for making custom API requests source (https://refine.dev/docs/guides-concepts/data-fetching#data-hooks). If you need to override specific functions of data providers, you can do so using the Spread syntax. Here's an example of how to override the update function of the @refinedev/simple-rest data provider source (https://refine.dev/docs/guides-concepts/faq#how-i-can-override-specific-function-of-data-providers):
import dataProvider from "@refinedev/simple-rest";

const simpleRestProvider = dataProvider("API_URL");
const myDataProvider = {
...simpleRestProvider,
update: async ({ resource, id, variables, meta }) => {
console.log("Overriding the update function");

// You can either send a request from scratch or use the original function
return await simpleRestProvider.update({ resource, id, variables, meta });
},
};

<Refine dataProvider={myDataProvider} />;
import dataProvider from "@refinedev/simple-rest";

const simpleRestProvider = dataProvider("API_URL");
const myDataProvider = {
...simpleRestProvider,
update: async ({ resource, id, variables, meta }) => {
console.log("Overriding the update function");

// You can either send a request from scratch or use the original function
return await simpleRestProvider.update({ resource, id, variables, meta });
},
};

<Refine dataProvider={myDataProvider} />;
For more information, you might find the Refine documentation (https://refine.dev/docs/data/data-provider) helpful. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4mo ago
<@777085367433166859> kapa.ai is still learning and improving, please let us know how it did by reacting below
dependent-tan
dependent-tan4mo ago
Can someone give their opinion on it?