graphql-compiler is a code-generation toolkit for GraphQL that transforms GraphQL queries and schemas into type-safe code for various target languages. Version 1.7.0 is the latest stable release, with infrequent updates. It differs from alternatives like graphql-codegen by focusing on compiler-level integrations (e.g., GraphQL Java, Python, or internal DSLs) rather than plugins. Peer dependency on graphql ^0.13.0 means it only works with older GraphQL.js, not modern versions. It supports ESM and CJS, but usage is limited due to the peerdep lock.
npm install graphql-compilerNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Compiles a GraphQL query into a code representation using CompilerContext and compileQuery.
Use an older version of graphql or consider alternative code generators.
Access compiled.source to get the generated code string.
Use named imports like import { compileQuery } from 'graphql-compiler' instead of default import.For TypeScript, install @types/graphql-compiler or use ts-ignore.
Run npm install graphql-compiler@1.7.0 graphql@0.13.0
Ensure query is a valid GraphQL string and schema is built correctly.
Install exact peer dependency: npm install graphql@0.13.0
Use import { CompilerContext } from 'graphql-compiler'