graph-tooling icon indicating copy to clipboard operation
graph-tooling copied to clipboard

Autogenerate IDs for entities that don't have relationships

Open nenadjaja opened this issue 7 years ago • 4 comments

Right now when building subgraphs, we need to set IDs for every entity in the mappings.ts file. That makes sense when entities are related to each other, but if they are not, it would be great to autogenerate those IDs (given that they are required).

nenadjaja avatar Sep 20 '18 23:09 nenadjaja

We could easily provide a helper to generate unique IDs, e.g.

let entity = new Entity()
...
store.set('MyEntity', store.uniqueId(), entity)

Would that be sufficient and good developer experience or can you think of a better way? I would still want the ID to be a thing the developer has to create somewhere, as opposed to automatically generating an ID behind the scenes.

Jannis avatar Sep 21 '18 08:09 Jannis

To add to the discussion:

I think something like a SEQUENCE would be great in some cases, i think that the struggle is managing to choose a value that is not only "natural or logical" but it's also a value that is either available on the events or on the contract. specially when managing historical data that might be deleted from the contract at some point and then written again with new values.

Jaime-Iglesias avatar Sep 16 '19 14:09 Jaime-Iglesias

Hello! Is this something that have been created since then?

dievardump avatar Mar 21 '21 23:03 dievardump

We did not get that feature request recently, so I'm not sure if this is needed. @dievardump would you be able to provide a real world use-case of this feature?

schmidsi avatar Feb 28 '23 17:02 schmidsi