graphprotocol / graphprotocol/graph-node

Stricter subgraph schema validation

Open
#1,682 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug validation
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 set and unset. AssemblyScript apparently allows things like

    entity.set = "foo"
    

    which will replace the set(key: string, value: Value) method in the Entity base 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

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.