Is it possible to query a child interface an get at the same time the parent one using @daml/react?

Hello,

i am using the useStreamQueries hook from @daml/react and I need to do a query using one interface that is child of another.

On that child interface i get only some partial part of the data that i need and i can use the queryFactory to filter the data. On the parent one there is the rest of the info that i need, but i cannot make use of the queryFactory to filter the data the way i need because that filter is not available on that interface.

My question would be, is there any possible way to achieve this without having to change the interfaces?

I could query both and then making use of Array.filter() and filter down by the contractID. But i would like to avoid to do 2 queries.

Any help or suggestion would be appreciated.
Thank you

2 Likes

Hello MaximTimeClock@Joao_Freitas ,

In @daml/react, the useStreamQueries hook is designed to query contracts based on a template or interface. If you need to query a child interface and simultaneously get information from the parent interface, you would typically need to perform two separate queries because each query is specific to a template or interface.

However, there might be a way to streamline this process without altering the interfaces. One approach could be to use the results from the child interface query to inform a subsequent query on the parent interface. This would involve using the contract IDs or keys obtained from the first query as parameters in the second query.

Best Regards

1 Like