graphprotocol / graphprotocol/docs
Current `store` interface is confusing when using `Bytes` `id`
Nobody has claimed this yet.
- Dominant language
- MDX
- Stars
- 85
- Forks
- 162
- Avg merge
- 6h 31m
- Merged PRs (30d)
- 4
Description
The functions in the store module (get, set, remove) are a bit confusing right now when subgraph use Bytes as their id; the host interface still requires that the id is passed as a string, for Bytes it needs to be id.toHexString(). For get and set, the difference is hidden by the code that graph-cli generates, so that subgraph authors can say Thing.get(id) no matter whether Thing uses String or Bytes for its ids.
But for remove, users need to use the 'raw' interface and write store.remove(id.toHexString()) which can be confusing.
I don't think we should actually change the calling convention for the store functions; instead, we should document this more clearly and explain how to work with these functions when id has type Bytes.
This was first reported as part of graphprotocol/graph-node#3476
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the store module documentation and review the get, set, and remove interfaces, especially the raw remove call. Document that Bytes IDs must be passed as id.toHexString(), explain why get and set may appear to accept the ID directly, and show the expected usage when the ID type is Bytes.
Written by the indexing model from the issue text.
Assessment
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100