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? Cheers
stormy-gold
stormy-goldβ€’453d ago
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 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.
optimistic-gold
optimistic-goldβ€’453d 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 users
eastern-cyan
eastern-cyanβ€’453d ago
Hey @nickwoods yes the method we recommend is sending with metaData.
eastern-cyan
eastern-cyanβ€’453d 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.
Omer
Omerβ€’452d ago
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.
optimistic-gold
optimistic-goldβ€’452d ago
Oh nice, I'll give it a try.. Thank you all for the great work πŸ™‚
More Posts
Error node-modules @pankod refine-coreI dnt know wha is the error or what it means or what to do to fix it.. the code still works normal ahow do I create a link that will not be on the sidebar?How do I create new routes snd links ghat will not show on the sider , but ll be distributed across how do I switch from google authentication to create a username and password?How can i create a login page where uder can create their username and password or login with as useRefine Layout for Header & FooterHi! I was reading docs & don’t quite understand how the Layout prop works for `<Refine>`. Currentlysearch multiple antd columns field from search boxhow can we search multiple columns field from a search boxHow to add Header into request GLOBALLYI want to add a header for each api call, since my API requires a X-API-KEY header. Anyone know how?Unable to obtain categories from refine strapi demo endpoint using refine, Strapi and chakraUIHello, I’m building a simple CRUD application using refine with a strapi-v4-provider and Chakra-UI amalfunction in installationHow do I go about this error because when I execute npm run dev, the terminal returns an error with reference to defining relations between collections in appwritethere is a reference in this page https://refine.dev/docs/advanced-tutorials/data-provider/appwrite/Disable Autocomplete in InferencersHi, I have two issues with the Autocomplete component in relation fields. A. With big resources, tReset sorting for useTableI have a reset button, which I am using to reset the sorting on the table. Btw I am also doing multiMultiple providers - don't neccesiate default provider?Hi guys, Opening it here for a discussion rather than a github issue. I use multiple providers, butAntd useDrawerForm not clearingWhat is the best way to clear the useDrawerForm when drawer is closed or when form is submitted? RigDefault access-control-casbin with next.js give warning of critical dependencyAfter integrating casbin with refine next.js project, I follow through boiler template but with next