graphprotocol / graphprotocol/graph-node

Stricter subgraph schema validation

Offen
#1,682 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug validation
Vorherrschende Sprache
Rust
Sterne
3.2k
Forks
1.1k
Ø Merge
4 T. 1 Std.
Gemergte PRs (30 T.)
1

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Das Issue nennt graph-cli und graph-node als Einstiegspunkte für die Validierung; beginne damit, nachzuverfolgen, wo Subgraph-Schemas während des Deployments oder der Codegenerierung geprüft werden. Reproduziere das bereitgestellte Schema und den Handler und stelle dann sicher, dass reservierte Namen wie set, unset sowie Entity- oder Feldnamen mit führendem Unterstrich vor dem Deployment oder Build abgelehnt werden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
graphql, rust
Bereich
backend-api-design, tooling
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.