Anyone who has ever tried to create distributed applications (dapps) on the blockchain (Ethereum) would agree: while the blockchain is conceptually quite close to databases, querying databases is completely different from querying a database.
Because it is difficult to query the data on the blockchain.
First, there are significant performance issues with storing data on the blockchain. It has a lot to do with the distributed nature of blockchains and a penalty imposed by the combination of consent and encryption protocols.
Databases would also be slow if they were made up of a network of nodes where each node kept a full copy of the entire database and each transaction had to be verified by each node. This is why people are experimenting with various approaches to using blockchain as a database, including changing the structure of the blockchain.
The Graph does something different: it leaves the blockchain as it is, but offers a way to efficiently index and query the data stored on it using GraphQL.
Querying the blockchain
In fact, performance is only part of the problem of retrieving data from blockchains. It’s even worse. The blockchain does not have a query language. Yes, you get it right, there is no query language. Imagine a database without a query language! How could you get what you need? How do people build dapps, really? With a lot of commitment and ad-hoc code.
As Jesus Rodriguez points out in this post, access to blockchain data is a challenge primarily for three reasons: decentralization, opacity, and sequential data storage. So there are still some choices:
Write custom code to locate the data they need on blockchain and repeat those (expensive) calls whenever they need the data, or retrieve the data once and store it in a non-blockchain database and create an index that points to the original blockchain data.
This is where the Graph comes in. Graph is a decentralized protocol for indexing and querying blockchain data. But it’s more than a protocol: the Graph also has an implementation, which is open source and uses GraphQL.
GraphQL is an open source query language for APIs developed by Facebook. GraphQL is growing in popularity and is also used to access databases; such as Prism or FaunaDB.
By defining a standardized way of performing this indexing and responding to queries deterministically, Tal adds, developers will be able to run their indexing logic on an open public infrastructure where security can be improved.
The Graph opened all of its core components, including: Graph Node (an implementation of the index node built into Rust), Graph TS (AssemblyScript helper for mapping), and Graph CLI (command line tools. to accelerate development).
Although the Graph has not yet reached full maturity, it has already come a long way in a short period of time. It is already considered an important part of the Web3 stack. In addition to the transition to fully decentralized implementation, we wondered what else was on the roadmap.
The Graph’s vision is to make dApp development on blockchain as easy as standard application development is today.