3

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.

mobiman
  • 619
  • 1
  • 11
  • 26
  • Could you paste the contents of your `mappings.ts`? Also, did you ran `graph codegen` to rebuild your types? It would also be useful to know whether you are running a graph node instance locally or via the hosting service. – jjperezaguinaga Jul 09 '21 at 14:20
  • Actually I see The Graph team has just released Subgraph Studio and now everything is working fine. So I guess it was just an issue with their legacy system. – mobiman Jul 15 '21 at 08:08

1 Answers1

2

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.

glinda93
  • 7,659
  • 5
  • 40
  • 78