Add custom query parameter with useList
Hi, is it possible to add a custom query parameter with
useList
(like ?custom-query=1
) or it should be done through metaData
and handled inside the dataProvider
?
What should be the better way to do this?
Cheers6 Replies
Hi, I am refine support bot :wave:. I am here to help you with your question. I searched for the answer to your question in the refine documentation and found an answer! 🏆
Answer: It is possible to add a custom query parameter with
Answer: It is possible to add a custom query parameter with
useList
by passing the queryOptions
or metaData
to the hook. It is recommended to use metaData
to pass additional information to data provider methods.
SOURCES: ./docs/api-reference/core/hooks/data/useCustom/index.md, ./docs/api-reference/core/hooks/data/useInfiniteList/index.md, ./docs/advanced-tutorials/data-provider/graphql.md, ./docs/api-reference/core/hooks/useTable/index.md
Note: If this is the answer you need, then we are very lucky. If not, please wait for someone from the refine core team or the community to try to help you.
rising-crimson•2y ago
Saw the support bot had a possible answer, is it possible to add this case to the
useList
documentation on the website? could be useful for other usersexotic-emerald•2y ago
Hey @nickwoods yes the method we recommend is sending with metaData.
exotic-emerald•2y ago
useList | refine
useList is an extended version of TanStack Query's useQuery. It supports all the features of useQuery and adds some extra features.
Hey @nickwoods ,
You can also use "resource" property of useList hook
useList({
resource: "categories?custom-query=1",
});
https://refine.dev/docs/api-reference/core/hooks/data/useList/#resource-
useList | refine
useList is an extended version of TanStack Query's useQuery. It supports all the features of useQuery and adds some extra features.
rising-crimson•2y ago
Oh nice, I'll give it a try.. Thank you all for the great work 🙂