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

Initialization handlers

Open azf20 opened this issue 3 years ago • 5 comments

Subgraph developers often want to initialise a specific state for their subgraph.

Currently this needs to be done across handlers, or on the basis of some other trigger.

TBD: could parts of this use case be handled declaratively in the manifest e.g. via context?

azf20 avatar Feb 07 '22 00:02 azf20

This was proposed separately in the Forum: https://forum.thegraph.com/t/grp-0001-decorator-hooks-cron-jobs-and-initialisation-handlers/3347

azf20 avatar Jun 16 '22 12:06 azf20

This could be a type of block handler, similar to #959:

blockHandlers
  - handler: initializeState
    filter:
      kind: once

azf20 avatar Jul 11 '22 12:07 azf20

@azf20 I like that, we'd just need to make sure it runs before any other triggers in the first block, rather than after as would be the default for a block handler.

leoyvens avatar Jul 11 '22 13:07 leoyvens

Interesting - I wonder if that could be a separate blockHandler configuration, unless that seems like too much of a footgun?

azf20 avatar Jul 11 '22 16:07 azf20

It does seem interesting to have a separate configuration to make any block handler be handled first. Like a field order: first|last, defaulting to last.

leoyvens avatar Jul 20 '22 13:07 leoyvens

@azf20 I like that, we'd just need to make sure it runs before any other triggers in the first block, rather than after as would be the default for a block handler.

Could we make it start 1 block before the earliest startblocks stated in subgraph.yaml thus ensuring no other handlers are triggered?

Data-Nexus avatar Sep 23 '22 19:09 Data-Nexus

Hey, is there an ETA on this?

adamazad avatar Jan 06 '23 22:01 adamazad