You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{SampleasSampleEvent}from"../../generated/SampleContractName/SampleContract";import{SampleEntity}from"../../generated/schema";import{STR_HARDCODED}from"../../../src/constants";// <-- issue is hereexportfunctionhandleSampleEvent(event: SampleEvent): void{constentity=newEntity(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{SampleasSampleEvent}from"../../generated/SampleContractName/SampleContract";import{SampleEntity}from"../../generated/schema";// import { STR_HARDCODED } from "../../../src/constants"; // <-- no longer import from dir parent to subgraphexportfunctionhandleSampleEvent(event: SampleEvent): void{constentity=newEntity(event.transaction.hash.toHex());entity.role="StrVal";// replaced with raw hardcoded string no longer importedentity.save();}
both codegen and build succeed
Let me know if any other info would help.
The text was updated successfully, but these errors were encountered:
undermethod
changed the title
Importing from parent directories causes UNCAUGHT EXCEPTION
Importing using wildcard export causes UNCAUGHT EXCEPTIONApr 25, 2022
Good call! Simply updating to the non-indexed path worked:
import{SampleasSampleEvent}from"../../generated/SampleContractName/SampleContract";import{SampleEntity}from"../../generated/schema";import{STR_HARDCODED}from"../../../src/constants/sampleconst";// <-- added path to avoid wildcardexportfunctionhandleSampleEvent(event: SampleEvent): void{constentity=newEntity(event.transaction.hash.toHex());entity.role=STR_HARDCODED;// <-- now able to reference without errorentity.save();}
/src/constants/
dir, itself containing:sampleconst.ts
:index.ts
:/subgraph/
contains (among others):package.json
/src/
(among others) contains:mappings/samplemapping.ts
containingcodegen
succeedsbuild
fails:codegen
andbuild
succeedLet me know if any other info would help.
The text was updated successfully, but these errors were encountered: