From bd5f53a2ee2b56071bb80887624b181bd8aa1b3a Mon Sep 17 00:00:00 2001 From: Adam Fuller Date: Fri, 16 Sep 2022 22:18:34 +0100 Subject: [PATCH] Add section on _meta (#201) * Add section on _meta * more fields to the block --- pages/en/querying/graphql-api.mdx | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/pages/en/querying/graphql-api.mdx b/pages/en/querying/graphql-api.mdx index a2f2bb5cf90e..1b81b65da234 100644 --- a/pages/en/querying/graphql-api.mdx +++ b/pages/en/querying/graphql-api.mdx @@ -316,3 +316,33 @@ GraphQL schemas generally define root types for `queries`, `subscriptions` and ` All GraphQL types with `@entity` directives in your schema will be treated as entities and must have an `ID` field. > **Note:** Currently, all types in your schema must have an `@entity` directive. In the future, we will treat types without an `@entity` directive as value objects, but this is not yet supported. + +### Subgraph Metadata + +All subgraphs have an auto-generated `_Meta_` object, which provides access to subgraph metadata. This can be queried as follows: + +```graphQL +{ + _meta(block: { number: 123987 }) { + block { + number + hash + timestamp + } + deployment + hasIndexingErrors + } +} +``` + +If a block is provided, the metadata is as of that block, if not the latest indexed block is used. If provided, the block must be after the subgraph's start block, and less than or equal to the most recently indexed block. + +`deployment` is a unique ID, corresponding to the IPFS CID of the `subgraph.yaml` file. + +`block` provides information about the latest block (taking into account any block constraints passed to _meta): +- hash: the hash of the block +- number: the block number +- timestamp: the timestamp of the block, if available (this is currently only available for subgraphs indexing EVM networks) + +`hasIndexingErrors` is a boolean identifying whether the subgraph encountered indexing errors at some past block +