How to Assess and Query Subgraphs on The Graph Network

The Graph By Jun 06, 2024 No Comments

Learn how to identify and query decentralized subgraphs on Builders Office Hours #35.

TL;DR: Learn to assess and query decentralized subgraphs on The Graph Network, with detailed guidance from Marcus of Edge & Node and featuring practical examples and resources for optimizing dApp development.

In this detailed session, Marcus, a developer relations specialist at Edge & Node, introduces viewers to the ins and outs of The Graph Network, a pivotal platform in decentralized application (dApp) development.

This blog post provides a structured overview of the session to help you understand The Graph Network and how to query and build on it—vital knowledge for blockchain developers.

Understanding The Graph Network

The Graph Network serves as a decentralized protocol for querying blockchain data efficiently. Marcus explains the network’s structure and functionality, highlighting its importance for decentralized indexing.

For deeper insights into the network’s framework, watch this 4-minute video, What is The Graph?

How to interact with and query The Graph Network

For developers looking to harness The Graph Network, Marcus offers detailed instructions on starting queries using GraphQL, along with other tools. The session includes practical examples and tips for navigating and using subgraphs to maximize dApp functionality and user experience.

To learn more about querying the network [timestamp: 2:25], check out the resources below.

It is not the answer that enlightens, but the question.

Eugene Ionesco, Playwright

“What are we curious about in web3 and what questions can we ask?” —Marcus Rein, Edge & Node

Steps to query a subgraph

Starting at timestamp 6:15

  • Set up an API key and keep it secure.
    • Obtain an API key. Ensure you store this key securely as it provides access to your subgraph and data. Your API key can be restricted to a specific subgraph or a specific domain if you choose.
  • Find and assess a subgraph on Graph Explorer.
    • Use Graph Explorer to locate the subgraph relevant to your needs. Assess its schema and data to ensure it fits your needs. You can search by name or deployment IDs. If you are looking for a total list of Messari subgraphs with standardized schemas, check the Messari subgraph webpage.
  • Design queries in the subgraph’s playground.
    • Use the playground feature of The Graph to design and test your queries. This environment allows you to experiment with different GraphQL queries to fetch the data you need from the subgraph.
  • Integrate query with dApp.
    • Once you have designed and tested your queries, integrate them into your decentralized application (dApp). Use the API key to authenticate your queries and retrieve data seamlessly.

Examples queries

Marcus then goes through some query examples using the CryptoPunks subgraph [timestamp 18:52].

  • What are the first 10 sales? [Timestamp 19:52]
  • What are the first 100 sales? Between two points in time? Or timestamps? [Timestamp 21:50]
  • What is the total value of all sales, the total supply, and the total number of sales on CryptoPunks contracts? [Timestamp 22:05]
    • Marcus shares a cool trick on how to reveal past queries and star your favorite ones for a later time [timestamp 22:52].

Multiple queries at the same time

Marcus shows us how to use Messari standard schema subgraphs [timestamp 25:20], where he sends a query to Curve and Sushiswap subgraphs at the same time to get total value locked using Graph Client.

Important update: upgrade window closing June 12

A crucial update in the session was the impending close of the Sunbeam upgrade window on June 12. Marcus stressed the urgency for developers to upgrade their hosted subgraphs to the decentralized network before this deadline to avoid disruptions and benefit from new features.

He also provided guidance on optimizing subgraphs for performance (sharing the links above). For details on optimization and the importance of updating in time, visit the session’s recording above.

Continue exploring

Now that you’ve learned valuable insights on how to effectively use The Graph Network for dApp development, continue to explore more resources like Graph Builders Office Hours, How to Tutorials, and Developer Guides to help you enhance your projects.

As the ecosystem continues to evolve, staying updated and integrating these practices will be crucial for developing scalable and efficient dApps.

💡 This article answers questions like:
- What is The Graph Network?
- How do developers query The Graph Network
- How do developers query a subgraph on the decentralized network?

I am a dedicated member of the Graph Advocates DAO and proud to be a part of the Graphtronauts community. As a passionate crypto investor and enthusiast, I have delved into the world of decentralized technologies, with a strong focus on The Graph protocol. My journey includes writing insightful blogs for Graphtronauts and contributing to the development of subgraph documentation for various projects within The Graph ecosystem. Most recently, I have taken on the role of a Pinax technical writer, further expanding my commitment to advancing the adoption and understanding of blockchain and Graph-based technologies. /n

No Comments

Leave a comment

Your email address will not be published. Required fields are marked *