subgraphs > Querying > Subgraph ID vs Deployment ID

Subgraph ID vs Deployment ID

Reading time: 2 min

A subgraph is identified by a Subgraph ID, and each version of the subgraph is identified by a Deployment ID.

When querying a subgraph, either ID can be used, though it is generally suggested that the Deployment ID is used due to its ability to specify a specific version of a subgraph.

Here are some key differences between the two IDs:

Deployment ID

Länk till detta avsnitt

The Deployment ID is the IPFS hash of the compiled manifest file, which refers to other files on IPFS instead of relative URLs on the computer. For example, the compiled manifest can be accessed via: https://api.thegraph.com/ipfs/api/v0/cat?arg=QmQKXcNQQRdUvNRMGJiE2idoTu9fo5F5MRtKztH4WyKxED. To change the Deployment ID, one can simply update the manifest file, such as modifying the description field as described in the subgraph manifest documentation.

When queries are made using a subgraph's Deployment ID, we are specifying a version of that subgraph to query. Using the Deployment ID to query a specific subgraph version results in a more sophisticated and robust setup as there is full control over the subgraph version being queried. However, this results in the need of updating the query code manually every time a new version of the subgraph is published.

Example endpoint that uses Deployment ID:

https://gateway-arbitrum.network.thegraph.com/api/[api-key]/deployments/id/QmfYaVdSSekUeK6expfm47tP8adg3NNdEGnVExqswsSwaB

The Subgraph ID is a unique identifier for a subgraph. It remains constant across all versions of a subgraph. It is recommended to use the Subgraph ID to query the latest version of a subgraph, although there are some caveats.

Be aware that querying using Subgraph ID may result in queries being responded to by an older version of the subgraph due to the new version needing time to sync. Also, new versions could introduce breaking schema changes.

Example endpoint that uses Subgraph ID: https://gateway-arbitrum.network.thegraph.com/api/[api-key]/subgraphs/id/FL3ePDCBbShPvfRJTaSCNnehiqxsPHzpLud6CpbHoeKW

Redigera sida

Tidigare
GraphQL API
Nästa
Python (Subgrounds)
Redigera sida