Relay Compiler Experimental

raw JSON →
0.0.1 verified Fri May 01 auth: no javascript deprecated

Experimental version of the Relay Compiler, part of Meta's Relay GraphQL client ecosystem. This package (v0.0.1) is an unstable pre-release intended for testing new compiler features before they migrate to the stable relay-compiler package. It follows the same release cadence as the main Relay monorepo but may introduce breaking changes without notice. Key differentiators: early access to compiler experiments, potential for rapid iteration, but no stability guarantees. Not recommended for production use.

error Error: Cannot find module 'relay-compiler-experimental'
cause Package not installed or not resolved correctly.
fix
Run 'npm install relay-compiler-experimental' or check package.json.
error SyntaxError: Unexpected token 'export'
cause Using CommonJS require with ESM-only package.
fix
Use ESM imports or set type: "module" in package.json.
error TypeError: relayCompiler is not a function
cause Importing default export incorrectly; package has named exports.
fix
Use named imports: import { compile } from 'relay-compiler-experimental'.
deprecated relay-compiler-experimental is no longer maintained; use relay-compiler instead.
fix Migrate to relay-compiler (stable) which includes most experimental features.
breaking Breaking changes may occur between minor versions without a major version bump.
fix Pin to exact version and test upgrades thoroughly.
gotcha Experimental features may conflict with stable relay-compiler artifacts; avoid using both in same project.
fix Use only one compiler package per project.
npm install relay-compiler-experimental
yarn add relay-compiler-experimental
pnpm add relay-compiler-experimental

Demonstrates compiling a GraphQL query with the experimental compiler, specifying schema and output directory.

import { compile } from 'relay-compiler-experimental';

const source = `
  query UserQuery {
    user(id: "1") {
      name
    }
  }
`;

const result = compile(source, {
  schemaPath: './schema.graphql',
  artifactDirectory: './__generated__',
});

console.log(result);