{"id":25652,"library":"graphql-jit","title":"graphql-jit","description":"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.","status":"active","version":"0.8.7","language":"javascript","source_language":"en","source_url":"https://github.com/zalando-incubator/graphql-jit","tags":["javascript"],"install":[{"cmd":"npm install graphql-jit","lang":"bash","label":"npm"},{"cmd":"yarn add graphql-jit","lang":"bash","label":"yarn"},{"cmd":"pnpm add graphql-jit","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: provides GraphQL schema and type system. Must be >=15.","package":"graphql","optional":false}],"imports":[{"note":"ESM-only since v0.8.5; named export, not default.","wrong":"const compileQuery = require('graphql-jit')","symbol":"compileQuery","correct":"import { compileQuery } from 'graphql-jit'"},{"note":"Type guard for compiled query objects. Available in ESM only.","wrong":"const { isCompiledQuery } = require('graphql-jit')","symbol":"isCompiledQuery","correct":"import { isCompiledQuery } from 'graphql-jit'"},{"note":"TypeScript type import for compiled query return type.","wrong":"","symbol":"CompiledQuery","correct":"import type { CompiledQuery } from 'graphql-jit'"}],"quickstart":{"code":"import { compileQuery } from 'graphql-jit';\nimport { validate, parse, buildSchema, GraphQLError } from 'graphql';\n\nconst schema = buildSchema(`\n  type Query { hello: String }\n`);\nconst requestString = '{ hello }';\nconst document = parse(requestString);\nconst errors = validate(schema, document);\nif (errors.length > 0) throw new Error(errors.map(e => e.message).join(', '));\n\nconst compiledQuery = compileQuery(schema, document);\nif ('query' in compiledQuery) {\n  const result = compiledQuery.query(null, {}, {}, {});\n  console.log(result);\n}\n","lang":"typescript","description":"Compile a simple GraphQL query and execute it. Shows schema building, parsing, validation, compilation, and execution."},"warnings":[{"fix":"Use Node.js 14+ (recommended 18+).","message":"Node.js 12 support dropped in v0.8.0","severity":"breaking","affected_versions":">=0.8.0"},{"fix":"Use import syntax or upgrade to Node 18+ with 'type': 'module' in package.json.","message":"Switched to ESM-only in v0.8.5, breaking CommonJS require()","severity":"breaking","affected_versions":">=0.8.5"},{"fix":"Check if 'query' key exists on the result before calling as function.","message":"compileQuery 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.","severity":"gotcha","affected_versions":">=0.4"},{"fix":"Migrate to the new default logic when the option is removed in future releases.","message":"The option 'useExperimentalPathBasedSkipInclude' is experimental and may be removed.","severity":"deprecated","affected_versions":">=0.8.1"},{"fix":"Upgrade to v0.8.6+ which fixes this issue.","message":"Non-null field returning null can cause TypeError in v0.8.5 with certain schemas.","severity":"gotcha","affected_versions":"==0.8.5"},{"fix":"Use import { compileQuery } from 'graphql-jit'.","message":"Default import (import graphqlJit from 'graphql-jit') does not exist; you must use named imports.","severity":"gotcha","affected_versions":">=0.8.5"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Replace `import graphqlJit from 'graphql-jit'` with `import { compileQuery } from 'graphql-jit'`.","cause":"Attempted to use default import instead of named import.","error":"TypeError: graphqlJit is not a function"},{"fix":"Ensure the same graphql version is used for schema building and compileQuery.","cause":"Schema object not passed correctly; often due to mixing graphql versions.","error":"RangeError: Invalid array length"},{"fix":"Install both: `npm install graphql-jit graphql`.","cause":"Missing peer dependency graphql or wrong module resolution.","error":"Cannot find module 'graphql-jit' or its corresponding type declarations."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}