Registry / web-framework / graphql-jit

graphql-jit

JSON →
library0.8.7jsnpmunverified

GraphQL JIT Compiler to JavaScript. Current stable version 0.8.7, released monthly. Compiles GraphQL queries into optimized JavaScript functions, offering up to 100x faster execution compared to graphql-js. Key differentiator: ahead-of-time compilation with runtime type validation, supports both ESM and CJS. Requires graphql >=15.

npm install graphql-jit
INSTALL
IMPORT
SIG · GRAPHQL-JIT
G
graphql-jit
web-frameworkjavascriptv0.8.7
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.

compileQuery
import { compileQuery } from 'graphql-jit'
const compileQuery = require('graphql-jit')
ESM-only since v0.8.5; named export, not default.
isCompiledQuery
import { isCompiledQuery } from 'graphql-jit'
const { isCompiledQuery } = require('graphql-jit')
Type guard for compiled query objects. Available in ESM only.
CompiledQuery
import type { CompiledQuery } from 'graphql-jit'
TypeScript type import for compiled query return type.

Compile a simple GraphQL query and execute it. Shows schema building, parsing, validation, compilation, and execution.

import { compileQuery } from 'graphql-jit'; import { validate, parse, buildSchema, GraphQLError } from 'graphql'; const schema = buildSchema(` type Query { hello: String } `); const requestString = '{ hello }'; const document = parse(requestString); const errors = validate(schema, document); if (errors.length > 0) throw new Error(errors.map(e => e.message).join(', ')); const compiledQuery = compileQuery(schema, document); if ('query' in compiledQuery) { const result = compiledQuery.query(null, {}, {}, {}); console.log(result); }
Debug
Known issues
breakingNode.js 12 support dropped in v0.8.0
fix
Use Node.js 14+ (recommended 18+).
affects: >=0.8.0
breakingSwitched to ESM-only in v0.8.5, breaking CommonJS require()
fix
Use import syntax or upgrade to Node 18+ with 'type': 'module' in package.json.
affects: >=0.8.5
gotchacompileQuery returns an object that may have 'query' or 'subscribe' properties, but also may throw a custom error if there is a validation issue. Not always a direct function.
fix
Check if 'query' key exists on the result before calling as function.
affects: >=0.4
deprecatedThe option 'useExperimentalPathBasedSkipInclude' is experimental and may be removed.
fix
Migrate to the new default logic when the option is removed in future releases.
affects: >=0.8.1
gotchaNon-null field returning null can cause TypeError in v0.8.5 with certain schemas.
fix
Upgrade to v0.8.6+ which fixes this issue.
affects: ==0.8.5
gotchaDefault import (import graphqlJit from 'graphql-jit') does not exist; you must use named imports.
fix
Use import { compileQuery } from 'graphql-jit'.
affects: >=0.8.5
Errors
Common errors & fixes
TypeError: graphqlJit is not a function
Attempted to use default import instead of named import.
fix
Replace `import graphqlJit from 'graphql-jit'` with `import { compileQuery } from 'graphql-jit'`.
RangeError: Invalid array length
Schema object not passed correctly; often due to mixing graphql versions.
fix
Ensure the same graphql version is used for schema building and compileQuery.
Cannot find module 'graphql-jit' or its corresponding type declarations.
Missing peer dependency graphql or wrong module resolution.
fix
Install both: `npm install graphql-jit graphql`.
Upgrade
Version history
0.8.7latest on npm
Audit
Dependencies
graphqlrequiredPeer dependency: provides GraphQL schema and type system. Must be >=15.
Agent activity
4 hits · last 30 days
node
4
Resources
graphql-jit — npm install graphql-jit · libregistry