Is there a way to call a trpc useQuery() multiple times?
I have a list of objects, and i would like to call the useQuery 1 time for every object in order to get some deta.
Is there a good way to do this?
27 Replies
The best method would probably be for you to refactor your query to take in multiple objects
this seems like such an oversight imo, might be wrong though
Can you give a bit more detail on what you're trying to do?
If you don't want to get all the data in one query the next best way is probably making a component that has the query attached
thats a smart workaround!
👍
thanks Pod!
np, gl!
@Christian Lind There is also this if it makes more sense for your use case https://trpc.io/docs/reactjs/usequeries
useQueries() | tRPC
The useQueries hook can be used to fetch a variable number of queries at the same time using only one hook call.
Which does have some nice benefits 👌
![](https://utfs.io/f/aed1bc8d-7030-4d61-9099-6489990e0b83-1nq2cb.png)
oo sweet
@Pod Could i ask you one more question? Its regarding prisma and joins?
For sure
Thanks mate!
I have 2 tables, and would like to do a classic inner join between them, How could i achieve this using prisma?
You can do something along the lines of
I have implemented it by using a query raw
select * from SeenQuestions JOIN Xyz on SeenQuestions.questionId = Xyz.id where Xyz.subcategory=${input.subCategory}
In that case - don't i have to add the relation in the prisma schema?Yes