graphprotocol / graphprotocol/graph-node
Stricter subgraph schema validation
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3.2k
- Forks
- 1.1k
- Avg merge
- 4d 1h
- Merged PRs (30d)
- 1
Description
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
We currently allow a lot of names in schemas that either cause problems or that we want to deliberately forbid in order to give us a reserved namespace. Examples are:
-
Entity fields called
setandunset. AssemblyScript apparently allows things likeentity.set = "foo"which will replace the
set(key: string, value: Value)method in theEntitybase class with a string, which breaks all later attempts to assign fields in the same handler. -
Entity types and fields with a leading underscore (we have already introduced the special
_Schema_type and we want to move towards reserving names starting with underscores for Graph features.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
Create a subgraph with a schema like this:
type Set @entity {
id: ID!
}
type SetCreation @entity {
id: ID!
set: Set!
name: String!
}
then write a handler that does the following:
let creation = new SetCreation("foo")
creation.set = "bar"
creation.name = "baz"
this will fail to compile.
What is the expected behavior?
We should catch problematic names at deploy (or even at codegen/build time) in graph-cli and graph-node.
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
The issue names graph-cli and graph-node as the validation entry points; start by tracing where subgraph schemas are checked during deploy or code generation. Reproduce the provided schema and handler, then ensure reserved names such as set, unset, and leading-underscore entity or field names are rejected before deployment or build.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, rust
- Domain
- backend-api-design, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100