R
Refine

ask-any-question

Automated Inferencer Setup

Rrare-sapphire4/25/2023
Hello Refine Community! I have a simple but sophisticated question about the inferencer (we're using AntdInferencer if that matters). Is there a way to automatically generate components (maybe from the CLI) based on pre-defined resources? I need to create 220 models in my case and that's around a thousand clicks :D. I don't have much hope, any hint is highly appreciated!
Kkapa.ai4/25/2023
Hi @bastianwegge. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Hello! The @refinedev/inferencer package provides a way to automatically generate views for your resources based on the data structure. In your case, you can use the <AntdInferencer/> component from @refinedev/inferencer/antd to generate CRUD pages based on your API response with Ant Design components source (https://refine.dev/docs/tutorial/getting-started/antd/generate-crud-pages). To use the <AntdInferencer/> component, you need to pass appropriate values to the resources prop of the <Refine/> component in App.tsx source (https://refine.dev/docs/tutorial/getting-started/antd/generate-crud-pages). Here's an example of how to use the <AntdInferencer/> component:
import { Refine } from "@refinedev/core";
import { AntdInferencer } from "@refinedev/inferencer/antd";
import dataProvider from "@refinedev/simple-rest";

const App = () => {
return (
<Refine
dataProvider={dataProvider("https://api.fake-rest.refine.dev")}
resources={[
{
name: "resource_name",
list: "/resource/list",
show: "/resource/show/:id",
create: "/resource/create",
edit: "/resource/edit/:id",
},
// Add more resources here
]}
>
<AntdInferencer />
</Refine>
);
};
export default App;
import { Refine } from "@refinedev/core";
import { AntdInferencer } from "@refinedev/inferencer/antd";
import dataProvider from "@refinedev/simple-rest";

const App = () => {
return (
<Refine
dataProvider={dataProvider("https://api.fake-rest.refine.dev")}
resources={[
{
name: "resource_name",
list: "/resource/list",
show: "/resource/show/:id",
create: "/resource/create",
edit: "/resource/edit/:id",
},
// Add more resources here
]}
>
<AntdInferencer />
</Refine>
);
};
export default App;
However, the inferencer components are meant to be used in development environments and not in production environments source (https://refine.dev/docs/packages/documentation/inferencer). Unfortunately, there isn't a CLI command to automatically generate components based on pre-defined resources. You'll need to manually define the resources in the resources prop as shown in the example above. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
Kkapa.ai4/25/2023
<@317433576721219584> kapa.ai is still learning and improving, please let us how it did by reacting below
Ssensitive-blue4/25/2023
You can use this https://refine.dev/docs/packages/documentation/cli/#create-resource if it's not meet your needs, please never hesitate to give feedback to us 🤞
CLI | refine
refine CLI is a command line application that allows you to interact with your refine project and perform some tasks. This includes creating a new resource, managing updates, swizzle components, and runs your project (build, start, dev).
Rrare-sapphire4/25/2023
Thank you very much @alicanerdurmaz !
Uunwilling-turquoise12/19/2023
Just in case this is helpful to anyone: CLI generation of Inferencer folder and files have been moved to the add resource function. https://refine.dev/docs/packages/cli/#resource
refine add resource your-resource-name-here
To make an additional request for future CLI improvements. Can a switch be added to inject the code that is auto-generated by the Inferencer feature into each file? Creation of these long forms is a massive time save.
CLI | refine
Refine CLI is a command line application that allows you to interact with your Refine project and perform some tasks. This includes creating a new resource, managing updates, swizzle components, and runs your project (build, start, dev).

Looking for more? Join the community!

R
Refine

ask-any-question

Join Server
Recommended Posts
Next Js on VercelHi, after deploying my app on vercel, there is no error while deploying. But I visit the app it thrusing multiple fields for the label in select ant designIs it possible to use multiple fields in the label of a select options prop from ant design exampleuseForm onFinish http getHow can i use a http get API call with userForm onFinish?MUI ButtonGroup useFormHi, I have a seach from and a grid. Now i wanted to put a formbutton group with a status in each bQuery string formatHello. I am using the fineFoods example as base. I created a new list page using another as examplHow to style sidebar in Nextjs & Antdesign appI want to make simple styling cahnges such as changing font weight in my Sider, but cannot seem to fNX with refineim trying to create a project where i wanted to create react app with refine and have it on nx.dev dlocalStorageHow can I access the local storage, I tried how next does it and it doesn't work for meauthorization token in refine apirefine api authorization tokensorting and filteringi'm tying to sort using location and filter using name. but unsure it what i have done on the serverState managementWhat is the canonical way to manage app state in Refine? I went through tutorial and it appears it dusage for useOne useShowHow can I do so that it does not return all the fields of the table, only some of them have some proBest practice of adding a link to a resourceHow can I add a link to a resource within a TextField? What is the best practice here?Dot Env settuphi @refine-support-bot how to setup dotenv on refine with react