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.
npm install graphql-import-nodeNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to register the hook and import a .graphql file as a DocumentNode
Ensure the hook is loaded before any GraphQL imports; in Jest use the provided jest transform instead.
Use `import 'graphql-import-node'` without curly braces or assigning to a variable.
Consider alternatives like graphql-tag/loader or custom ESM loader for .graphql files.
Run `npm install graphql-import-node` and ensure it's in your package.json dependencies.
Run `npm install graphql` to install the peer dependency.
Use `import * as schema from './schema.graphql'` (namespace import) because the module exports a DocumentNode object, not a default export.