graphprotocol / graph-node

Graph Node indexes data from blockchains such as Ethereum and serves it over GraphQL
https://thegraph.com
Apache License 2.0
2.92k stars 978 forks source link

[Bug] Derived loader doesn't behave as expected #5608

Open Crismon96 opened 3 months ago

Crismon96 commented 3 months ago

Bug report

When using a derived loader I get a confusing error. My basic setup is this:

// SCHEMA
type Pool {
  # `Pool-${token0.toHexString()}-${token1.toHexString()}`
  id: ID!
  stakingPool: StakingPool
}
type StakingPool {
  id: Bytes!
  liquidityPool: Pool!
}

// WHEN ADDING THE POOL FIRST
poolEntity.stakingPool = idOfFutureStakingPool;

const stakingPool = StakingPool.load(poolAddress)!;
const lp = stakingPool.liquidityPool.load()[0];

The last line is crashing with the error: Mapping aborted at ~lib/@graphprotocol/graph-ts/common/value.ts, line 80, column 5, with message: Value is not a string.

What am I doing wrong? I didn't find any documentation for this modifier or any other for the subgraph. Also if I did anything wrong shouldn't the loader return an empty array instead of exploding in my face?

Using the derived field works well (in inspecting the store) but using the loader doesn't.

Relevant log output

No response

IPFS hash

No response

Subgraph name or link to explorer

No response

Some information to help us out

OS information

Linux