flat-fuchsia
flat-fuchsia2y ago

queryOptions

I want to hit an Api with a specific route, for exampe, lets say api/user-directories/ for example to show a root directory. how can I use queryOptions on a table to be able to add those query parameters to the query? I'm totally stuck on this. const {tableProps, sorter} = useTable<any>({ initialSorter: [ { field: "id", order: "desc", }, ], initialPageSize: 25, queryOptions: { queryKey: 'path', } });
20 Replies
Omer
Omer2y ago
Hey @rothwulf 👋 , Thanks for reaching out to us. Could this be what you're looking for? https://refine.dev/docs/faq/#how-can-i-request-an-api-with-nested-route
flat-fuchsia
flat-fuchsia2y ago
Thank you very much @Omer. Let me check please and try in my codebase. I really appreciate it. No @Omer It didn't work. when I add the nested route here, I don't hit the api from the backend.
Omer
Omer2y ago
Sorry, I didn't understand exactly what you want to do
flat-fuchsia
flat-fuchsia2y ago
i need to make a query to a route of a Api with this kind of structure for example: api/v1/profile-directories?path=%2F Because I don't know how to pass the query parameters using queryOptions: const {tableProps, sorter} = useTable<any>({ initialSorter: [ { field: "id", order: "desc", }, ], initialPageSize: 25, queryOptions: }); I have no idea about what I should pass in queryOptions for passing that path=%2F query parameter. Sorry if I don't have too much knowledge about react-query, but this is related to React Query.
Omer
Omer2y ago
Aha okay. You can use "metaData" for this. Could you check out this doc? https://refine.dev/docs/faq/#how-i-can-override-specific-function-of-data-providers
FAQ | refine
How can I change the form data before submitting it to the API?
flat-fuchsia
flat-fuchsia2y ago
Sure, thank you very much. I really appreciate your help @Omer
Omer
Omer2y ago
If it doesn't work, just let us know. We will be happy to assist you ⚡️
flat-fuchsia
flat-fuchsia2y ago
Thank you very much. Sorry @Omer I don't really understand how to use it. I didn't sleep all night trying to solve this issue. Something like this:? const {tableProps, sorter} = useTable<any>({ initialSorter: [ { field: "id", order: "desc", }, ], initialPageSize: 25, resource: "<path with query parameters here?", metaData: { httpMethod: "patch", } }); But this requires to modify the App.js and I was asking to only touch the file with the table. and to use queryOptions according to my team.
Omer
Omer2y ago
General Concepts | refine
- refine core is fully independent of UI. So you can use core components and hooks without any UI dependency.
flat-fuchsia
flat-fuchsia2y ago
Sure, but there is not a way to use the queryOptions?
Omer
Omer2y ago
You can't with queryOptions. You can pass data to your dataProvider using metaData 🚀
flat-fuchsia
flat-fuchsia2y ago
Thank you very much @Omer, then, I'll better discuss with my team about this.
flat-fuchsia
flat-fuchsia2y ago
Thank you very much @Omer Hi @Omer can I ask you one more question please?
Omer
Omer2y ago
Yes
flat-fuchsia
flat-fuchsia2y ago
Thank you very much.
flat-fuchsia
flat-fuchsia2y ago
In the case that for example, the fields of a table like the table you showed me, were not just records, but for example folders. How can I implement a functionality that shows me the contect of each folder with a click. I'm sorry for asking too much. Just I started with Refine two days ago and it's being a little bit hard to understand the whole entire system. At the moment I'm trying, using useShow and useCustom but I'm not pretty sure.
No description
Omer
Omer2y ago
Don't worries 🍻 Is this what you are looking for? https://refine.dev/docs/examples/table/react-table/advanced-react-table/
flat-fuchsia
flat-fuchsia2y ago
let me check please and thanks a lot! No @Omer, not really. Similar but when I click a button I need to see the content of each listed item (considering that the item is a directory).
Omer
Omer2y ago
Sorry, I don't understand exactly what you want to do. Have you finished the refine tutorials? https://refine.dev/docs/
Tutorials | refine
Introduction