Skip to content

[BUG] camelCase to snake-case conversion issue during graph init #1679

@marcusrein

Description

@marcusrein

Which packages are impacted by your issue?

@graphprotocol/graph-cli

Describe the issue

I attempted to deploy a subgraph on Moonbeam on a live demo today and ran into this error:

✖ Failed to deploy to Graph node https://api.studio.thegraph.com/deploy/: Could not deploy subgraph on graph-node: subgraph deployment error: store error: The `id` field has type `BigInt` but only `String`, `Bytes`, `Int8`, and `ID` are allowed. Deployment: QmRkH3mWEwUxAtg7CHkuVi4sozH8boj2pxkiWFxKGBYryb
UNCAUGHT EXCEPTION: Error: EEXIT: 1

Smart contract address: 0xb89279DEd0AD7cD573D164b03424E1E2BbE1e2Be

The subgraph was an init subgraph and all the schema entity ids are Bytes.

graph-cli is 0.73.0.

I was able to deploy a subgraph that was indexing an ethereum smart contract right afterwards without issue.

@lutter provided context to this issue:

"I see the schema has fields like _id: BigInt (e.g. on EnteredGame) That causes the issue: we internally convert GraphQL field names from camel case to snake case (fieldName -> field_name) The library we use for that unfortunately translates _id to id and that makes graph-node think you have a id: BigInt in your schema. Try renaming those fields, and things should work."

Reproduction

graph-cli

Steps to Reproduce the Bug or Issue

See issue description ⬆️

Expected behavior

graph-cli should continue through its init process.

If this error is unavoidable at this time, an error code could display such as:

Failed to deploy to Graph node: Could not deploy subgraph on graph-node: subgraph deployment error: store error: The `id` field has type `BigInt` but only `String`, `Bytes`, `Int8`, and `ID` are allowed.

Cause: Schema has fields like _id: BigInt, incorrectly converted to id by our internal library, making the graph-node think there is an id: BigInt.

Fix: Rename entity fields to avoid starting with an underscore (_). For example, rename _id to id.

UNCAUGHT EXCEPTION: Error: EEXIT: 1

Screenshots or Videos

No response

Platform

  • OS: MacOS
  • NodeJS: v20.13.1
  • @graphprotocol/graph-cli v0.73.0

Subgraph Manifest

No response

Subgraph GraphQL Schema

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions