Open
Description
- root git dir contains (among others)
/src/constants/
dir, itself containing:sampleconst.ts
:along withexport const STR_HARDCODED = "StrVal";
index.ts
:export * from "sampleconst.ts";
- child dir
/subgraph/
contains (among others):package.json
- "@graphprotocol/graph-cli": "^0.29.0",
- "@graphprotocol/graph-ts": "^0.26.0",
- schema, manifest, lock file, locally installed dependencies
/src/
(among others) contains:mappings/samplemapping.ts
containingimport { Sample as SampleEvent } from "../../generated/SampleContractName/SampleContract"; import { SampleEntity } from "../../generated/schema"; import { STR_HARDCODED } from "../../../src/constants"; // <-- issue is here export function handleSampleEvent(event: SampleEvent): void { const entity = new Entity(event.transaction.hash.toHex()); entity.role = STR_HARDCODED; entity.save(); }
- performing a
codegen
succeeds - performing a
build
fails:Error: Failed to compile data source mapping: assertion failed at Compiler._compileDataSourceMapping (/Users/path/subgraph/node_modules/@graphprotocol/graph-cli/src/compiler/index.js:307:13) at /Users/path/subgraph/node_modules/@graphprotocol/graph-cli/src/compiler/index.js:216:20 at updateInDeepMap (/Users/path/subgraph/node_modules/immutable/dist/immutable.js:1971:22) at updateInDeepMap (/Users/path/subgraph/node_modules/immutable/dist/immutable.js:1980:23) at updateInDeepMap (/Users/path/subgraph/node_modules/immutable/dist/immutable.js:1980:23) at Map.updateIn (/Users/path/subgraph/node_modules/immutable/dist/immutable.js:1278:26) at /Users/path/subgraph/node_modules/@graphprotocol/graph-cli/src/compiler/index.js:215:24 at /Users/path/subgraph/node_modules/immutable/dist/immutable.js:3016:46 at List.__iterate (/Users/path/subgraph/node_modules/immutable/dist/immutable.js:2206:13) at IndexedIterable.mappedSequence.__iterateUncached (/Users/path/subgraph/node_modules/immutable/dist/immutable.js:3015:23) UNCAUGHT EXCEPTION: Error: The AssemblyScript compiler crashed when compiling this file: 'src/mappings/samplemapping.ts' Suggestion: try to comment the whole file and uncomment it little by little while re-running the graph-cli until you isolate the line where the problem happens. Also, please contact us so we can make the CLI better by handling errors like this. You can reach out in any of these links: - Discord channel: https://discord.gg/eM8CA6WA9r - Github issues: https://github.com/graphprotocol/graph-cli/issues error Command failed with exit code 1.
- simply commenting out the above import and replacing with the hardcoded string itself:
import { Sample as SampleEvent } from "../../generated/SampleContractName/SampleContract"; import { SampleEntity } from "../../generated/schema"; // import { STR_HARDCODED } from "../../../src/constants"; // <-- no longer import from dir parent to subgraph export function handleSampleEvent(event: SampleEvent): void { const entity = new Entity(event.transaction.hash.toHex()); entity.role = "StrVal"; // replaced with raw hardcoded string no longer imported entity.save(); }
- both
codegen
andbuild
succeed
Let me know if any other info would help.
Metadata
Metadata
Assignees
Type
Projects
Status
No status