Latest news about Bitcoin and all cryptocurrencies. Your daily crypto news habit.
A highly anticipated feature is coming to the Internet Computer: composite queries! This feature allows canisters to call other canisters while they are handling queries. Composite queries (previously known as inter-canister query calls) are key for building composable and scalable dapps.
Before this feature was launched, developers had to write complex JavaScript orchestration code on the browser side of their dapp in order to query data from multiple canisters. Now, client code (e.g. JavaScript libraries) can query a single canister, which in turn queries other canisters. Besides improving user-visible latency, this also allows developers to keep the client-side code simple and support use cases where developers don’t have access to all client libraries.
Composite queries are crucial for dapps that use multiple canisters for sharding data and balancing load. While composite queries already enable developers to scale their dapps horizontally, and simplify client-side code, they have certain limitations. The current version requires canisters of the dapp to be on the same subnet. Another temporary restriction is that composite queries cannot be executed in replicated mode, which means they cannot be called from an update method and cannot be executed as updates. We are planning to lift these restrictions in the future and allow cross-subnet query calls, as well as replicated execution.
An example of how to use composite query calls can be found in the partitioned key-value store example, where data is stored across multiple backend canisters. Here, the JavaScript code in the browser makes a single composite query call to the frontend canister, which in turn queries one or more backend canisters, and returns the result to the client. For more technical information, please see the documentation.
We’re eager to see the amazing new things developers will create using composite queries in their work. Stay tuned for future updates as we improve this feature. We’ll be adding functions, like calls across different networks and replicated execution to make composite queries even more powerful.
Happy coding!
- The DFINITYÂ Team
Learn more about the internetcomputer.org and join the developer community at @DFINITYDev.
Learn more:
Technical documentation
Technical blog post
Motion proposal
Composite Queries: Horizontal Scaling for Multi Canister Dapps was originally published in The Internet Computer Review on Medium, where people are continuing the conversation by highlighting and responding to this story.
Disclaimer
The views and opinions expressed in this article are solely those of the authors and do not reflect the views of Bitcoin Insider. Every investment and trading move involves risk - this is especially true for cryptocurrencies given their volatility. We strongly advise our readers to conduct their own research when making a decision.