The Graph Demystified - Fetching Data From The Limitless Blockchain Bookshelves
Stipe
Posted on March 13, 2024
As a curious man I was reading about the graph protocol. Since I am not a blockchain developer I wasn't aware of challenges when you are in need of grabbing certain data from a particular location on the blockchain. I found it interesting how Graph works and I think it is a good idea to share with others what I have learned and how I understood it. So let's get started.
Standard definition:
The Graph enables indexing and querying of data from various blockchains. It facilitates efficient and performant access to complex data sets, such as those from smart contracts and NFTs. These APIs(subgraphs) are queried with GraphQL.
More in official docs: https://thegraph.com/docs/en/about/
All humans common language definition:
Finding needle in the Blockchain data haystack, this is what Graph let's you to do in quick and easy way.
The Graph is not Google of blockchains. However, unlike Google where users directly type in search queries to find information, The Graph is used by developers. They integrate The Graph into their applications (web3 or Dapp) to query blockchain data efficiently. So, it's like Google's powerful indexing and data retrieval capabilities, but specialised for the world of blockchain data, accessible through a developer's toolkit rather than a simple search bar.
There are 3 roles in the system:
Indexor
Delegator
Curator
I will use analogy to explain each role in the system, so it's easier to understand.
Imagine Graph is gigantic library. Library is full of book. Someone needs to maintain those books, keep them in order, suggest new books that should be added to the library, add new books, and keep entire library running smoothly and safely. So lets get started.
Librarian = Indexor
Helper/Investor = Delegator
Book Scout = Curator
Library user = Graph user
------------------------
Graph = Library
Subgraph = Book
Now imagine a scenario, you are a research student/library user and you need to find certain information for your thesis. Next day you decide to visit library and see if they have a book that contains data that you need.
It's Monday, 08:00h in the morning, library just opened, inside the library are librarian
(indexor) and the book scout
(curator).
Book Scout
(Curator) has been very busy. He has been exploring various sources, looking for Books that contain unique, valuable, or particularly relevant data. When he finds a Book that meets these criteria, he signals its value to the Library with a "recommendation" tag, which effectively is communicated to the Librarians (Indexors). It then is prioritised for acquisition.
This is how books
(Subgraphs) are added to the library
(Graph)
At roughly 08:30h, you (the student
) are entering the library. Inside the library you are welcomed by the librarian
(indexor), a knowledgeable individual, who manages the organisation and accessibility of the books (subgraphs).
In a short chat, you explain what kind of topic you are searching, and librarian
(indexor) points you (graph user) to a particularly well-regarded book (subgraph) that covers exactly what they need.
Now when I have found the book I need, I am ready to borrow it but I only need one piece of information from the book. Good old librarian explains me that there is a new technique where I can take with me a particular piece of the book if I want. That new technique seems like a great idea, he explains that I can specify a "list of data
" (GraphQL query) of certain chapters (fields) and he will service me with exact info that I chose. So this is what I did. I submitted a list to the librarian (sent a query to indexor), who found data in that book (subgraph) and delivered me exactly what I wanted. Wow, super nice!!!
It's important to note that Library's vast collection of books and its organised state are partially thanks to Helper/Investor
(Delegator) who, although not actively participating in the day-to-day management, has invested resources into the Library. His support enables the Librarian to maintain and expand the Library's collection, ensuring that it remains a valuable resource for all library users.
In return Helper/Investor (Delegator) is rewarded with a portion of the profit.
Library user is amazed with how good the library ecosystem is functioning. Helper/Investor helps with his resources (GRT token), book scout (curator) busy as a bee searching and suggesting new great books (subgraphs), while good old librarian (indexor) is always there to serve in best possible way. Therefore in this harmony of collaborative effort they are providing library users (graph users) with access to exact data they need in efficient and accurate way.
If you have thoughts on how you see the Graph ecosystem, or you would like to add to this analogy, make sure to comment.
Posted on March 13, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
March 13, 2024