A Quick Glance
- The Proof of Concept for the GraphQL layer can be accessed at https://ckb-graphql.vercel.app/api.
- For a super lightweight explorer built on the GraphQL layer, visit https://ckb-urchin.vercel.app.
- The repository for this project is located at https://github.com/homura/ckb-urchin.
Below is an example that demonstrates how to use GraphQL playground to interact with the CKB testnet. Thanks to the GraphQL ecosystem, we can easily try out the GraphQL layer through Vercel.
view the above query
query Block {
block {
header {
number
}
transactions {
inputs {
cellOutput {
capacity
lock {
args
codeHash
hashType
}
}
}
outputs {
capacity
lock {
args
codeHash
hashType
}
}
}
}
}
I have also created a super lightweight explorer to showcase the usage. You can access it online at https://ckb-urchin.vercel.app (currently, only the transaction view is supported). This demonstration highlights that the GraphQL layer can function without needing an additional server, allowing us to utilize the layer directly within the browser.
The explorer is also compatible with your own devnet. Simply modify the
urchin-config
in the browser’s local storage to {“url”:“https://localhost:8114”,“network”:“ckb_testnet”}.
Why
This project aims to address several challenges, including:
- Connecting CKB dApps with GraphQL to enhance the dApps ecosystem.
- Sharing knowledge efficiently, as I have frequently encountered recurring questions like “How to find a block of a transaction” or “How to find a transaction of a cell.”
- Simplifying the process of connecting various pieces of data, which can be complex and unintuitive with JSON RPC.
- Automating the handling of RPC requests, such as batch requests, to free from manually scheduling requests.
- Find a good practice for building custom indexers
GraphQL
GraphQL offers many benefits, such as self-documenting, strongly typed, and most importantly, it can be used to build a data mesh, which means we can reach some related data through a single request, such as resolving an OutPoint
s to a cell or a DepGroup
to its cell and deriving its data hash or type hash. GraphQL can also help us learn the relationships between each piece of data.
Furthermore, GraphQL has a huge community which means there are through of reusable components available and good practices, such as IDE plugins, SDKs, and design patterns.
If you find these interesting ideas, please let me know, such as
- Creating a module to help integrate the GraphQL layer to the js projects as an alternative to interacting with RPC
- Developing a lightweight explorer that is compatible with the local devnet
- Expanding functionality to support custom indexers and integration with other mature programs like Prisma
- …