I'm following The Graph documentation (https://thegraph.com/docs/quick-start#hosted-service) and creating a subgraph using the following code:
graph init <GITHUB_USERNAME>/<SUBGRAPH_NAME>
When I build and then deploy I see in the Playground there is a default query named exampleEntities():
{
  exampleEntities(first: 5) {
    id
    affiliate
    player
    points
    total
  }
}
If I query the subgraph using this default query everything is fine, but if I change the name of the entity type to anything else - for example affiliateData - in my schema.graphql file (and change the import name in mapping.ts) I get this error:
"No value provided for required argument: `id`"
Again, all I am doing is changing the name of the entity type from this:
type ExampleEntity @entity {
  id: ID!
  affiliate: Bytes! # address
  player: Bytes! # address
  points: BigInt!
  total: BigInt!
}
To this:
type affiliateData @entity {
  id: ID!
  affiliate: Bytes! # address
  player: Bytes! # address
  points: BigInt!
  total: BigInt!
}
I'm not sure how the "id" is set in the ExampleEntity entity type, as I can't find anywhere in the code where it is being set. I'm hoping someone can offer a bit of insight.
In my case, it was because of using plural name for entity.
I had an entity named Analytics, the build and deployment were all successful, but when I sent a query as the following, I got the exact same error message:
analytics {
  id
}
I renamed entity to Analytic and the error was gone.
I guess subgraph automatically pluralize the entity name but seems like there is a conflict when entity name is already pluaralized.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With