Registry / web-framework / relay-compiler-plus

relay-compiler-plus

JSON →
library1.8.3jsnpmunverified

Custom Relay Modern compiler that adds persisted query support, allowing developers to generate query IDs, null query text in production, and a queryMap.json for server-side query resolution. Current version 1.8.3 works with Relay Compiler v1.6 and Node v10. Key differentiator: supports direct compilation from graphql-js schema files (schema.js) in addition to schema.graphql or schema.json, enabling a single-step build pipeline. Last updated 2019, likely inactive.

npm install relay-compiler-plus
INSTALL
IMPORT
SIG · RELAY-COMPILER-PLU
R
relay-compiler-plus
web-frameworkjavascriptv1.8.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.

matchQueryMiddleware
import { matchQueryMiddleware } from 'relay-compiler-plus'
const matchQueryMiddleware = require('relay-compiler-plus').matchQueryMiddleware
ESM named export; CJS also works with proper destructure.
default (relay-compiler-plus binary)
npx relay-compiler-plus --schema <path> --src <path>
require('relay-compiler-plus').cli()
CLI tool is run via command line, not imported.
queryMap.json
import queryMapJson from '../queryMap.json'
const queryMapJson = require('../queryMap.json')
JSON import works with bundlers; CJS require also valid.

Demonstrates installation, CLI usage to generate persisted queries, server-side middleware setup, and client fetch modification.

// Install yarn add relay-compiler-plus // Generate persisted queries NODE_ENV=production npx relay-compiler-plus --schema schema.graphql --src ./src // Server: use matchQueryMiddleware import express from 'express'; import expressGraphql from 'express-graphql'; import {matchQueryMiddleware} from 'relay-compiler-plus'; import queryMapJson from './queryMap.json'; const app = express(); app.use('/graphql', matchQueryMiddleware(queryMapJson), expressGraphql({ schema: MySchema, graphiql: true }) ); // Client: send queryId instead of query function fetchQuery(operation, variables) { return fetch('/graphql', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ queryId: operation.id, // generated by relay-compiler-plus variables, }), }).then(res => res.json()); }
relay-compiler --version
Debug
Known issues
deprecatedRelay Compiler Plus is no longer actively maintained. Consider using the official Relay Compiler's built-in persisted query support (available since Relay v3) or relay-persisted-query-directive.
fix
Migrate to Relay Compiler with –persist-config or use relay-persisted-query-directive from GraphQL Tada.
affects: >=1.0.0
gotchaNODE_ENV=production must be set to strip query text from compiled files. Without it, query text is included, negating the security benefit of persisted queries.
fix
Always prefix the command with NODE_ENV=production.
affects: >=1.0.0
gotchaThe generated schema.graphql file (when using graphql-js source) is placed outside src folder to avoid relay-compiler conflicts. Adjust your project layout accordingly.
fix
Ensure schema.graphql is one level above src (e.g., ../src).
affects: >=1.0.0
breakingBreaking: Requires relay-compiler v1.6.x. Incompatible with newer Relay versions (v2+).
fix
Stick with Relay v1.6.x or use alternative persisted query solution for newer Relay.
affects: >=1.8.0
Errors
Common errors & fixes
Error: Cannot find module 'relay-compiler'
Missing peer dependency relay-compiler.
fix
Install relay-compiler@1.6.x: yarn add relay-compiler@1.6.0
Error: graphql is not installed or too old
Missing graphql-js dependency or outdated version.
fix
Upgrade graphql to latest: yarn upgrade graphql --latest
Error: ENOENT: no such file or directory, open '.../queryMap.json'
relay-compiler-plus did not generate queryMap.json, usually because NODE_ENV=production was omitted.
fix
Ensure you run with NODE_ENV=production or check that the src path is correct.
Error: 'matchQueryMiddleware' is not a function
Incorrect import of matchQueryMiddleware (e.g., default import instead of named).
fix
Use named import: import { matchQueryMiddleware } from 'relay-compiler-plus'
Upgrade
Version history
1.8.3latest on npm
Audit
Dependencies
relay-compilerrequiredRelay Compiler Plus extends the official relay-compiler
graphqlrequiredRequires graphql-js for schema parsing and query text
Agent activity
7 hits · last 30 days
node
6
Bingbot
1
Resources
relay-compiler-plus — npm install relay-compiler-plus · libregistry