Perform Query
Short description on what this section is about
After deploying your subgraph, you can easily access and query it via GraphQL playground for query. You can open the “GraphQL API” link in your dashboard to access your data.
For example, you may access the publicly available Apechain token approval subgraph at https://apeapi.0xgraph.xyz/subgraphs/name/token-transfer/graphql
Query for Subgraph Sync Status
To get to know the sync status directly inside the subgraph, a user may run the following query by using _meta
:
The result would be similar to the following:
Query a Subgraph
Subgraphs expose blockchain data via a GraphQL API, making it easy for anyone familiar with the GraphQL language to get started.
A GraphQL API differs from traditional REST APIs in that it relies on a schema definition to outline the available queries, mutations, and data types that clients can access.
Benefits of Schema-Driven Approach
This schema-driven approach enables clients to precisely specify the data they need, eliminating the need to over-fetch data. Here’s why this is beneficial:
Precision
GraphQL clients can tailor their queries to retrieve only the data they require, enhancing efficiency.
Flexibility
Clients can request related data in a single query, reducing the number of API calls needed.
Predictability
The schema provides clear documentation for available data and operations.
GraphQL Syntax
GraphQL queries are composed using a specific syntax that allows for hierarchical data retrieval. Clients specify the fields they want to retrieve and their relationships within a single query. This approach minimizes unnecessary data retrieval, resulting in more concise and efficient requests.
Best Practices
When working with the 0xgraph service, it’s essential to follow best practices to ensure optimal performance and efficiency. These best practices are outlined in official Graph Protocol documentation.
For detailed instructions on querying 0xgraph using GraphQL and to ensure adherence to best practices, refer to the official documentation provided by the Ormi Labs and Graph Protocol teams. These resources offer valuable insights and recommendations to streamline your interaction with blockchain data through GraphQL.