Consultando > 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. However, there are some important differences between the two options.

Subgraph ID

Enlace a esta sección

The Subgraph ID is a unique identifier for a subgraph. It remains constant across all versions of a subgraph. When queries are made using the Subgraph ID, you are not specifying a version. This means that the version of the subgraph that responds to your query may not be the latest version. Rather, it will be the most recent version that is synced and healthy.

Example endpoint that uses Subgraph ID:

https://gateway-arbitrum.network.thegraph.com/api/[api-key]/subgraphs/id/FL3ePDCBbShPvfRJTaSCNnehiqxsPHzpLud6CpbHoeKW

Deployment ID

Enlace a esta sección

When you're viewing a deployed subgraph, previously deployed versions are available for selection. Each version in that list has a unique Deployment ID.

When you make queries using the Deployment ID, you are specifying a version of that subgraph to query. This means that the version of the subgraph that responds to your query will be the version specified by the Deployment ID.

Example endpoint that uses Deployment ID:

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

Considerations When Using Subgraph ID vs Deployment ID

Enlace a esta sección

If you want to ensure that the latest version of your subgraph responds to your queries, you should use the Deployment ID. This requires you to update the Deployment ID in your frontend whenever you publish a new version of your subgraph.

If you want to ensure you are querying a specific version of your subgraph, you should also use Deployment ID.

If you do not need to ensure that the latest version of your subgraph always responds to your queries, you can use the Subgraph ID. However, be aware that this may result in your queries being responded to by an older version of your subgraph.

Editar página

Anterior
API GraphQL
Siguiente
Python (Subgrounds)
Editar página