graphprotocol / graphprotocol/docs

Current `store` interface is confusing when using `Bytes` `id`

Open
#115 3 comments 2 reactions 0 assignees View on GitHub

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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.