graphprotocol / graphprotocol/graph-node

[Bug] Derived loader doesn't behave as expected

Open
#5,608 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Stale
Dominant language
Rust
Stars
3.2k
Forks
1.1k
Avg merge
4d 1h
Merged PRs (30d)
1

Description

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
  • Tick this box if this bug is caused by a regression found in the latest release.
  • Tick this box if this bug is specific to the hosted service.
  • I have searched the issue tracker to make sure this issue is not a duplicate.
OS information

Linux

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the derived-loader example from the issue, then inspect lib/@graphprotocol/graph-ts/common/value.ts around line 80, where the reported error occurs. Trace how stakingPool.liquidityPool.load() handles the schema and mapping shown; done means identifying whether the usage or loader is at fault and documenting or correcting the expected behavior.

Written by the indexing model from the issue text.

Assessment

Domain
blockchain
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.