Skip to main content

@polywrap/schema-bind#

Bind WRAP ABIs to a variety of supported languages through codegen.

Usage#

import { BindOptions, BindOutput, bindSchema } from "@polywrap/schema-bind";
import { parseSchema } from "@polywrap/schema-parse";
const schema = fetch("schema.graphql");
const abi = parseSchema(schema);
const input: BindOptions = {
projectName: "Test",
bindLanguage: "wasm-as",
abi,
schema,
outputDirAbs: "/path/to/output/dir"
};
const output: BindOutput = bindSchema(input);

Details#

Polywrap uses MessagePack as a common data interchange format between languages. This allows Polywrap WASM modules, authored in different languages, to be run within a single host language (JS, Rust, Python, Go, C#, C++).

MessagePack encoded data is sent between module boundaries. Decoding of the message will happen in the destination environment, using generated binding code, created by this package.

Supported Schema Types#

GraphQL Schema TypeMessagePack TypeDescription
UIntuint 3232-bit unsigned integer.
UInt8uint 88-bit unsigned integer.
UInt16uint 1616-bit unsigned integer.
UInt32uint 3232-bit unsigned integer.
Intint 3232-bit signed integer.
Int8int 88-bit signed integer.
Int16int 1616-bit signed integer.
Int32int 3232-bit signed integer.
Stringfixstr or str 8/16/32UTF-8 string.
Booleanbooltrue or false stored as 1 byte.
Bytesbin 8/16/32array of 8-bit unsigned integer.
BigIntfixstr or str 8/16/32UTF-8 string.
BigNumberfixstr or str 8/16/32UTF-8 string.
JSONfixstr or str 8/16/32UTF-8 string.
[Type]fixarray or array 16/32Array of elements.
MapMsgpack extention typeMap of key-value pairs.
type CustomObject {
  prop: Type
}
fixmap or map 16/32Structured object.