{"id":26185,"library":"relay-compiler-plus","title":"Relay Compiler Plus","description":"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.","status":"maintenance","version":"1.8.3","language":"javascript","source_language":"en","source_url":"https://github.com/yusinto/relay-compiler-plus","tags":["javascript","relay","compiler","persisted","queries","query","custom","modern"],"install":[{"cmd":"npm install relay-compiler-plus","lang":"bash","label":"npm"},{"cmd":"yarn add relay-compiler-plus","lang":"bash","label":"yarn"},{"cmd":"pnpm add relay-compiler-plus","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Relay Compiler Plus extends the official relay-compiler","package":"relay-compiler","optional":false},{"reason":"Requires graphql-js for schema parsing and query text","package":"graphql","optional":false}],"imports":[{"note":"ESM named export; CJS also works with proper destructure.","wrong":"const matchQueryMiddleware = require('relay-compiler-plus').matchQueryMiddleware","symbol":"matchQueryMiddleware","correct":"import { matchQueryMiddleware } from 'relay-compiler-plus'"},{"note":"CLI tool is run via command line, not imported.","wrong":"require('relay-compiler-plus').cli()","symbol":"default (relay-compiler-plus binary)","correct":"npx relay-compiler-plus --schema <path> --src <path>"},{"note":"JSON import works with bundlers; CJS require also valid.","wrong":"const queryMapJson = require('../queryMap.json')","symbol":"queryMap.json","correct":"import queryMapJson from '../queryMap.json'"}],"quickstart":{"code":"// Install\nyarn add relay-compiler-plus\n\n// Generate persisted queries\nNODE_ENV=production npx relay-compiler-plus --schema schema.graphql --src ./src\n\n// Server: use matchQueryMiddleware\nimport express from 'express';\nimport expressGraphql from 'express-graphql';\nimport {matchQueryMiddleware} from 'relay-compiler-plus';\nimport queryMapJson from './queryMap.json';\n\nconst app = express();\napp.use('/graphql',\n  matchQueryMiddleware(queryMapJson),\n  expressGraphql({ schema: MySchema, graphiql: true })\n);\n\n// Client: send queryId instead of query\nfunction fetchQuery(operation, variables) {\n  return fetch('/graphql', {\n    method: 'POST',\n    headers: { 'Content-Type': 'application/json' },\n    body: JSON.stringify({\n      queryId: operation.id, // generated by relay-compiler-plus\n      variables,\n    }),\n  }).then(res => res.json());\n}","lang":"javascript","description":"Demonstrates installation, CLI usage to generate persisted queries, server-side middleware setup, and client fetch modification."},"warnings":[{"fix":"Migrate to Relay Compiler with –persist-config or use relay-persisted-query-directive from GraphQL Tada.","message":"Relay 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.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Always prefix the command with NODE_ENV=production.","message":"NODE_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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure schema.graphql is one level above src (e.g., ../src).","message":"The generated schema.graphql file (when using graphql-js source) is placed outside src folder to avoid relay-compiler conflicts. Adjust your project layout accordingly.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Stick with Relay v1.6.x or use alternative persisted query solution for newer Relay.","message":"Breaking: Requires relay-compiler v1.6.x. Incompatible with newer Relay versions (v2+).","severity":"breaking","affected_versions":">=1.8.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install relay-compiler@1.6.x: yarn add relay-compiler@1.6.0","cause":"Missing peer dependency relay-compiler.","error":"Error: Cannot find module 'relay-compiler'"},{"fix":"Upgrade graphql to latest: yarn upgrade graphql --latest","cause":"Missing graphql-js dependency or outdated version.","error":"Error: graphql is not installed or too old"},{"fix":"Ensure you run with NODE_ENV=production or check that the src path is correct.","cause":"relay-compiler-plus did not generate queryMap.json, usually because NODE_ENV=production was omitted.","error":"Error: ENOENT: no such file or directory, open '.../queryMap.json'"},{"fix":"Use named import: import { matchQueryMiddleware } from 'relay-compiler-plus'","cause":"Incorrect import of matchQueryMiddleware (e.g., default import instead of named).","error":"Error: 'matchQueryMiddleware' is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}