This tool compiles data source definitions for WASM runtime of The Graph.
the-graph-wasm takes a data-source.yaml data source definition (with references
to a GraphQL schema, smart contract ABIs and data source mappings written in
TypeScript/AssemblyScript), compiles the mappings to WASM and outputs a ready-to-use
version of the data source.
An example of this can be found in examples/memefactory/.
- Install the package
yarn add the-graph-wasm
- Add the following
tsconfig.json:{ "extends": "./node_modules/the-graph-wasm/tsconfig.json", "files": ["mapping.ts"] } - Add a GraphQL schema file and a data source definition.
- Add the following to
package.json:{ "scripts": { "codegen": "the-graph-wasm generate-types data-source.yaml", "build": "the-graph-wasm compile data-source.yaml" } } - Generate TypeScript type definitions from contract ABIs used in the
data source via:
yarn codegen
- Develop your
mapping.tsagainst those generated types. - Build with
yarn build
npm install -g https://github.com/graphprotocol/the-graph-wasm
the-graph-wasm compile data-source.yaml