Skip to main content

Loading Entities with Labels

Deprecation Warning

This feature is planned for deprecation in a future release. We recommend not relying on it to facilitate easier upgrades in the future.


In the basic section to get values loaded into your handler into you have used the get function. This is great when starting out, but when your indexer is further along you may want to use labels to make the connection between the load and get parts explicit. This can make your code look cleaner, and avoid sneaky bugs where the wrong entity is being loaded or the load and get function aren't matching up.

For loading a single entity you will use a label, but for an array you can use the tag arrayLabels in config.yaml file. This is useful for groups of entitites that you want to have in your handler, and the entities stay ordered for easy iteration. For example, you may want to load two token entities for an event from an AMM pool that you are indexing.


The below example illustrates how to define an arrayLabel as well as a label for entity A that we want to load for TestEvent event.


- id: 12345 #Your chain Id
- name: Greeter
# ... other fields
- event: "TestEvent"
- name: "A"
- "allAs"
- "singleA"
# ... rest of your config file


type A {
id: ID!
someField: String!

Event Handler file

GreeterContract.TestEvent.loader(({ event, context }) => {
context.A.allALoad(["id1", "id2", "id3"])
// ... other loaders
GreeterContract.TestEvent.handler(({ event, context }) => {
let arrayOfAs = context.A.allA
let singleA = context.A.singleA

// ... rest of the handler that uses or updates these entities.