Does @daml/react work with interfaces?


I was wondering if it is possible to query an interface from the generated @daml/react.

Jose Velasco

Yes. If you take a look at the documentation for the synchronous useQuery, and asynchronous useStreamQueries, you’ll note they accept a TemplateOrInterface argument rather than the prior Template argument. If your @daml/react is new enough to have this signature, its accompanying TypeScript codegen should also generate values representing your interfaces to be passed in as the argument here. (edit: your codegen version and @daml/react version should be kept in sync.)

Note that as with the underlying JSON API streaming queries only allow one interface ID at a time, so not all useStreamQueries calls you might imagine will work.