Registry / testing / relay-compiler-playground

relay-compiler-playground

JSON →
library0.0.3jsnpmunverified

Web-based Wasm playground for the Rust Relay compiler. Current stable version 0.0.3 (2023-08-28). Compiled via wasm-pack targeting web browsers. Key differentiator: brings the Rust Relay compiler to the browser for interactive testing. Not intended for production use—mainly a demo/tool for the Relay website.

npm install relay-compiler-playground
INSTALL
IMPORT
SIG · RELAY-COMPILER-PLA
R
relay-compiler-playground
testingjavascriptv0.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import init, { relay_compiler_playground } from 'relay-compiler-playground'
import relay from 'relay-compiler-playground'
ESM-only. Requires dynamic import or init() to load Wasm.
init
import init from 'relay-compiler-playground/relay_compiler_playground'
const init = require('relay-compiler-playground')
init is a default export from the Wasm module; ESM only.
relay_compiler_playground
import { relay_compiler_playground } from 'relay-compiler-playground'
import { RelayCompilerPlayground } from 'relay-compiler-playground'
The main function is named snake_case. Check the .d.ts file for exact signatures.

Initialize Wasm module and compile a simple GraphQL schema and document.

import init, { relay_compiler_playground } from 'relay-compiler-playground'; async function run() { await init(); const input = { schema: 'type Query { hello: String }', document: '{ hello }' }; const result = relay_compiler_playground(JSON.stringify(input)); console.log(result); } run();
Debug
Known issues
gotchaPublished package missing 'relay_compiler_playground_bg.js' in files array. Manual fix required.
fix
Edit package.json to include the missing file as shown in README before publishing.
affects: 0.0.3
gotchaWasm-pack bug causes missing entry in files array; issue #837.
fix
Manually add 'relay_compiler_playground_bg.js' to package.json files array.
affects: 0.0.3
breakingESM only. No CommonJS support.
fix
Use import syntax; do not use require().
affects: >=0.0.0
gotchaMust call init() before using main function. Wasm loading is async.
fix
Await init() in an async context.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'relay-compiler-playground'
Package may not be installed or missing from node_modules.
fix
npm install relay-compiler-playground
Module parse failed: Unexpected token (1:0)
Webpack may not be configured to handle Wasm.
fix
Use webpack 5 with experiments.syncWebAssembly: true.
Error: [relay_compiler_playground] input must be a valid JSON string
Input not serialized to JSON.
fix
JSON.stringify({ schema, document }) before passing.
Upgrade
Version history
0.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
relay-compiler-playground — npm install relay-compiler-playground · libregistry