Development and deployment FAQ

1、Is there a requirement for the format of the subgraph creation naming?

Yes, it is strongly recommended to name your subgraphs in the format required on the HyperGraph console page. When adding a subgraph, you can only fill in the name composed of lowercase letters,-and numbers, such as subgraphdemo, dodoex-v2, etc., and the actual subgraph deployed on the HyperGraph network will be: "subgraph name/public chain name", That is, the name displayed in the details of the console sub-picture. If the resolved contract is on the Heco network, the subgraph name is: "subgraphdemo/heco", if the resolved contract is on the BSC network, and the subgraph name is: "subgraphdemo/bsc".

2、Which networks are currently supported to create subgraphs?

At present, HyperGraph supports the creation of subgraphs of contracts on high-performance blockchain networks such as Heco and BSC, and will support more networks in the future, including Heco, BSC testnet, other high-performance blockchain networks based on EVM, and even Ethernet Fang network。

3、Is the same subgraph name supported on different networks?

For the time being, the subgraph names in the HyperGraph network are globally unique. Even in different networks, they cannot have the same name. The system will also give a test, please follow the prompts.

4、Is it possible to change the deployment type, such as the Github type at the beginning, and adjust it to API deployment?

Does not support self-adjustment of deployment methods, if you have special needs, please contact technical support for adjustment

5、Do you support renamed or deleted sub-picture deployment?

Temporarily does not provide sub-map deployment to rename or delete.

6、Where does the data source of the subgraph index come from?

The data of the subgraph index generally comes from the contract. Events are defined in the contract. The indexing program will retrieve blocks according to the contract, analyze the events for analysis and storage, and form a query data source. Just as calling a contract in web3.js requires ABI and other information, the same is true in subgraph development.

7、For data query, any suggestions for contract writing?

For the data that needs to be queried, it is recommended to use events for correlation in the contract. This is the quickest way to index subgraph data. It is also highly recommended.

If the contract does not contain events, the subgraph can use contract calls and block processors to trigger the index, but in this case, the speed will be much slower。

8、Can graph init support multiple contracts to create subgraphs?

The graph init command is used to create a scaffold for an initial project, so the function is not very complicated, so it does not support multiple contracts to create subgraphs. If you want to add multiple contracts, you can add more data sources to the configuration file later.

9、I want to get the status of the data index, is there a way?

HyperGraph provides the function of querying the health status of each network in the console.

The Heco network is: https://h.hg.network/graphql/playground

The BSC network is: https://ph.hg.network/graphql/playground

The typical GraphQL query is:

{
 indexingStatusesForSubgraphName(subgraphName:"pancakeswap/blocks") {
 subgraph
 health
 synced
 fatalError {
 handler
 message
 deterministic
 }
 nonFatalErrors {
 handler
 }
 chains {
 chainHeadBlock {
 number
 __typename
 }
 latestBlock {
 number
 __typename
 }
 }
 }
}

You can replace "pancakeswap/blocks" in the above code with the subgraph you want to query.

If there are multiple versions, you can also replace indexingStatusesForSubgraphName in the above query with:

"indexingStatusForCurrentVersion" or "indexingStatusForPendingVersion" for targeted query.

10、Can I use subgraph codes from other projects for indexing?

When the sub-picture code is disclosed, data query and indexing can be performed based on the sub-picture code of other projects.

11、Can I use development libraries such as ethers.js in subgraph development?

Since the subgraph development is written in AssemblyScript, this kind of library cannot be used. It is recommended that if there are other libraries that need to call the data, you can use the library you want to call the data on the query side after the data is stored.

12、What is the processing sequence of contract events in the subgraph?

In the sub-picture, the order of event processing is consistent with their order in the block. It has nothing to do with the number and order of monitored contracts.

13、Can information such as the network and contract address of the data source be obtained in the code?

Yes, by introducing "graph-ts", use the following sample code:

import { dataSource } from '@graphprotocol/graph-ts'
dataSource.network()
dataSource.address()

14、Is there any way to improve the performance of subgraph indexing?

The deployment network of HyperGraph has been optimized to a certain extent, allowing users to quickly add subgraphs and index data. For user-added subgraph query programs, it is strongly recommended to use startBlock in subgraph.yaml to specify a block to start indexing. Generally, the starting block is designated as the block where the contract is created.

15、Is there a plan for the combined query of subgraph queries?

Indeed, in some businesses, an application or page requires a large number of query requests. A gateway for query sub-graph query merging has been planned and developed to achieve sub-graph query caching, connection reuse, etc., to improve query performance effectiveness.

16、How many pieces of data can be retrieved at most during query?

By default, each query set returns 100 pieces of data. If you want to query more data, you can use a paged query code, such as:

someCollection(first: 1000, skip: <number>) { ... }

To query at most 1000 data at a time

Last updated