2

我正在关注 Graph 文档(https://thegraph.com/docs/quick-start#hosted-service)并使用以下代码创建子图:

graph init <GITHUB_USERNAME>/<SUBGRAPH_NAME>

当我构建然后部署时,我在 Playground 中看到有一个名为exampleEntities()的默认查询:

{
  exampleEntities(first: 5) {
    id
    affiliate
    player
    points
    total
  }
}

如果我使用此默认查询查询子图,一切都很好,但是如果我在我的schema.graphql文件中将实体类型的名称更改为其他任何名称 - 例如附属数据(并在 mapping.ts 中更改导入名称),我得到这个错误:

"No value provided for required argument: `id`"

同样,我所做的只是更改实体类型的名称:

type ExampleEntity @entity {
  id: ID!
  affiliate: Bytes! # address
  player: Bytes! # address
  points: BigInt!
  total: BigInt!
}

对此:

type affiliateData @entity {
  id: ID!
  affiliate: Bytes! # address
  player: Bytes! # address
  points: BigInt!
  total: BigInt!
}

我不确定如何在 ExampleEntity 实体类型中设置“id”,因为我在代码中找不到设置它的任何地方。我希望有人可以提供一些见解。

4

0 回答 0