Inferencer customize query
Hello! Can someone please tell me how I can customize the request in the Inferencer for graphql query, how can i specified variables like "where" or "sort"



22 Replies
Hi @cyy. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
In refine, you can customize the GraphQL query by using the
meta
property in the Inferencer component. The meta
property allows you to define values for your resources and methods in a single prop, and it is used when generating the code and inferring the fields.
Here's an example of how you can define the meta
values in Inferencer components:
In this structure, default
is the default meta
value for all the methods. If a specific meta
value for a method for a resource is not provided, the default
value will be used.
Here's an example usage:
In this example, the getList
method for the posts
resource will only fetch the fields id
, title
, content
, category_id
, and created_at
. For the categories
resource, the default
method will fetch the fields id
and title
.
For more complex queries like "where" or "sort", you might need to use the custom
method in the data provider. This method allows you to handle requests with custom parameters like URL, CRUD methods, and configurations. You can find more information about the custom
method in the refine documentation (https://refine.dev/docs/api-reference/core/providers/data-provider/).
Please note that the actual implementation of the "where" or "sort" parameters will depend on your GraphQL server's API.
For more information, you can check out the refine documentation on Inferencer (https://refine.dev/docs/packages/documentation/inferencer/).
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------<@710818953974251553> kapa.ai is still learning and improving, please let us know how it did by reacting below
rare-sapphireOP•2y ago
@kapa.ai
Let me check the knowledge base for you. One moment! :books:
Sorry @cyy, I seem to be having a bit of trouble. Don't worry though, I've pinged my supprt and they will try to fix me up! :technologist:
Perhaps try again in 15mins?
rare-sapphireOP•2y ago
this means I can’t pass "filters" or "where" to the Inferencer as in a custom request through a dataProvider?
@kapa.ai
Let me check the knowledge base for you. One moment! :books:
Sorry @cyy, I seem to be having a bit of trouble. Don't worry though, I've pinged my supprt and they will try to fix me up! :technologist:
Perhaps try again in 15mins?
rare-sapphireOP•2y ago
@kapa.ai this means I can’t pass "filters" or "where" to the Inferencer as in a custom request through a dataProvider?
Let me check the knowledge base for you. One moment! :books:
----------------------
Based on the provided extracts, the Inferencer in refine does not directly support passing "filters" or "where" clauses. The Inferencer is primarily used to generate sample codes for your views and infer the fields of the data provider's response.
However, refine provides several hooks and methods that allow you to pass filter parameters to your data provider. For example, hooks like
useList
, useInfiniteList
, useExport
, useAutocomplete
, and useSelect
all accept a filters
property that can be used to send filter query parameters to the API. Here's an example usage with useList
:
In this example, the getList
method from the dataProvider
will be called with the provided filters.
For more complex or custom requests, you can use the custom
method from the dataProvider
. This method is passed to the useCustom
hook and can be used to send custom filter query parameters of the request.
In this example, the custom
method from the dataProvider
will be called with the provided filters.
For more information, you can refer to the refine documentation (https://refine.dev/docs/).
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------<@710818953974251553> kapa.ai is still learning and improving, please let us know how it did by reacting below
multiple-amethyst•2y ago
Hey @cyy
Inferencer is a powerful tool in the refine ecosystem that helps developers quickly generate CRUD (create, read, update, delete) pages for their data model. It analyzes your data model based on the resource scheme and automatically creates the pages with the required forms and tables for CRUD operations.
There is no direct filtering support. Put the generated code in the
list
file and save it. You can then filter and sort.
https://refine.dev/docs/api-reference/antd/hooks/table/useTable/#initial-filter-and-sorter
I would also suggest you review the permanent
filter section.
https://refine.dev/docs/api-reference/antd/hooks/table/useTable/#filterspermanentrare-sapphireOP•2y ago
@yildirayunlu I'm just trying to figure out how to solve my problem because the Inferencer makes a request which doesn't suits to my api
maybe I misunderstood the concept

multiple-amethyst•2y ago
Hi, if the inferencer is generating a wrong query, you should create a list page using the useTable hook.
rare-sapphireOP•2y ago
I have the same issue with all refine hooks
Third day was spent on doc searching
multiple-amethyst•2y ago
Hi, can you make a codesandbox to understand the problem clearly?
rare-sapphireOP•2y ago
I'm not sure I can make codesandbox because of nda
rare-sapphireOP•2y ago
my graphQL client and data provider


rare-sapphireOP•2y ago
then Inferencer makes such request

rare-sapphireOP•2y ago
but i need to pass this variables instead "start", "limit" e.t.c.

correct-apricot•2y ago
Hi @cyy Inferencer doesn't provide you a complete solution, it's meant to save you some time during development, if inferencer doesn't get it right, you should write those compionents, queries yourself. Don't expect it to be produce production ready-code.
rare-sapphireOP•2y ago
@batuhanw Hi, but i have the same story with hooks (like useList)
correct-apricot•2y ago
Then you can swizzle your data provider and use it as you need. Please read documentation throoughly.
https://refine.dev/docs/tutorial/understanding-dataprovider/swizzle/
https://refine.dev/docs/tutorial/understanding-dataprovider/create-dataprovider/#getlist
https://refine.dev/docs/tutorial/understanding-dataprovider/index/#supported-data-providers
2. Create a data provider with swizzle | refine
What is swizzle?
3. Create a data provider from scratch | refine
Introduction
1. Data Provider | refine
The Data Provider unit is optional for the tutorial. You can directly skip to the next unit, Adding CRUD PagesAdding CRUD PagesAdding CRUD PagesAdding CRUD PagesAdding CRUD Pages, if desired
rare-sapphireOP•2y ago
I really didn't find it, what I need
Thank you