{"id":47881,"library":"graphql-import-node","title":"graphql-import-node","description":"Enables Node.js to import `.graphql` files as compiled GraphQL DocumentNode objects using require.extensions. Current stable version is 0.0.5 (last release). Low maintenance, no recent updates. Differs from alternatives (e.g., webpack graphql-tag/loader) by being a simple Node.js hook without bundler dependency. Requires peer dependency `graphql` and must be loaded before any GraphQL file imports. Supports CommonJS, ESM (via import), TypeScript (with typings), and Jest.","status":"active","version":"0.0.5","language":"javascript","source_language":"en","source_url":"https://github.com/ardatan/graphql-import-node","tags":["javascript","typescript"],"install":[{"cmd":"npm install graphql-import-node","lang":"bash","label":"npm"},{"cmd":"yarn add graphql-import-node","lang":"bash","label":"yarn"},{"cmd":"pnpm add graphql-import-node","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency – generates DocumentNode objects that are part of the GraphQL package","package":"graphql","optional":false}],"imports":[{"note":"Default import not provided; use side-effect import.","wrong":"import graphql-import-node","symbol":"register hook","correct":"import 'graphql-import-node'"},{"note":"No explicit type export; importing the module side-effect adds typings for .graphql files.","wrong":"","symbol":"TypeScript type declaration","correct":"import 'graphql-import-node'"},{"note":"Configure in Jest's transform map, not an import.","wrong":"","symbol":"Jest transform","correct":"\"^.+\\.graphql$\": \"graphql-import-node/jest\""}],"quickstart":{"code":"// Install: npm install graphql-import-node graphql\n// In your entry file (e.g., index.js):\nrequire('graphql-import-node/register');\n// or with ES modules:\nimport 'graphql-import-node';\n// Then import .graphql files:\nconst typeDefs = require('./schema.graphql');\n// import * as typeDefs from './schema.graphql'; // TypeScript\nconsole.log(typeDefs); // DocumentNode object","lang":"typescript","description":"Shows how to register the hook and import a .graphql file as a DocumentNode"},"warnings":[{"fix":"Ensure the hook is loaded before any GraphQL imports; in Jest use the provided jest transform instead.","message":"Use of require.extensions can interfere with other tools (e.g., Jest custom transforms) if not properly configured.","severity":"breaking","affected_versions":"all"},{"fix":"Use `import 'graphql-import-node'` without curly braces or assigning to a variable.","message":"The package must be imported as a side-effect; there is no default or named export. Attempting to import a symbol will fail.","severity":"gotcha","affected_versions":"all"},{"fix":"Consider alternatives like graphql-tag/loader or custom ESM loader for .graphql files.","message":"Package has not been updated in several years; may not work with newer Node.js versions (e.g., ESM-only projects).","severity":"deprecated","affected_versions":"all"}],"env_vars":null,"search_vec":"'/loader':38 '0.0.5':22 'altern':32 'bundler':46 'commonj':62 'compil':12 'current':18 'depend':47,50 'differ':30 'documentnod':14 'e.g':33 'enabl':5 'esm':63 'file':10,59 'graphql':2,9,13,36,51,58 'graphql-import-nod':1 'graphql-tag':35 'hook':44 'import':3,8,60,65 'javascript':71 'jest':70 'last':23 'load':55 'low':25 'mainten':26 'must':53 'node':4 'node.js':6,43 'object':15 'peer':49 'recent':28 'releas':24 'requir':48 'require.extensions':17 'simpl':42 'stabl':19 'support':61 'tag':37 'type':68 'typescript':66,72 'updat':29 'use':16 'version':20 'via':64 'webpack':34 'without':45","created_at":"2026-06-07T16:53:48.371673+00:00","updated_at":"2026-06-07T16:53:48.371673+00:00","problems":[{"fix":"Run `npm install graphql-import-node` and ensure it's in your package.json dependencies.","cause":"Missing or incorrect installation (e.g., devDependencies vs dependencies).","error":"Cannot find module 'graphql-import-node/register'"},{"fix":"Run `npm install graphql` to install the peer dependency.","cause":"Missing or incompatible peer dependency `graphql`.","error":"TypeError: (0 , _graphql.parse) is not a function"},{"fix":"Use `import * as schema from './schema.graphql'` (namespace import) because the module exports a DocumentNode object, not a default export.","cause":"Using `import schema from './schema.graphql'` (default import) instead of `import * as schema`.","error":"Unexpected token '.' in JSON at position 0"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/ardatan/graphql-import-node","github":"https://github.com/ardatan/graphql-import-node","docs":null,"changelog":null,"pypi":null,"npm":"graphql-import-node","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}