{"id":47880,"library":"graphql-import-loader","title":"graphql-import-loader","description":"Webpack loader for graphql-import that resolves GraphQL import statements (e.g., `# import { Type } from './type.graphql'`) in `.graphql` files. Current version 0.2.1, last updated in 2018. This package is unmaintained; the repository is archived. It was part of the deprecated Graphcool ecosystem. Alternatives: use `graphql-import` directly with `raw-loader` or `@graphql-tools/load` and `@graphql-tools/graphql-file-loader`. The loader returns the imported schema as a string.","status":"deprecated","version":"0.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/graphcool/graphql-import-loader","tags":["javascript","graphql","import","webpack","loader","module","typescript"],"install":[{"cmd":"npm install graphql-import-loader","lang":"bash","label":"npm"},{"cmd":"yarn add graphql-import-loader","lang":"bash","label":"yarn"},{"cmd":"pnpm add graphql-import-loader","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides the core import resolution logic; this loader is a thin wrapper.","package":"graphql-import","optional":false}],"imports":[{"note":"Since the loader returns a string, the import can be used as a default import or require. However, if using ES modules, use the import statement as shown. Using require may cause issues with webpack's ES module detection.","wrong":"const typeDefs = require('./schema.graphql')","symbol":"graphql-import-loader (webpack rule)","correct":"import typeDefs from './schema.graphql'"},{"note":"Omitting the array brackets is valid but uncommon. The loader works with a single string or object configuration.","wrong":"use: 'graphql-import-loader'","symbol":"webpack use config","correct":"use: [{ loader: 'graphql-import-loader' }]"},{"note":"To use the imported string inside TypeScript, you must provide a declaration file for .graphql modules. Without it, TypeScript will error.","wrong":"No type declaration","symbol":"TypeScript type","correct":"declare module '*.graphql' { const content: string; export default content; }"}],"quickstart":{"code":"// Install\n// npm install --save-dev graphql-import-loader\n\n// webpack.config.js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.graphql$/,\n        exclude: /node_modules/,\n        use: [{ loader: 'graphql-import-loader' }]\n      }\n    ]\n  }\n};\n\n// schema.graphql\n# import { User } from './user.graphql'\ntype Query {\n  users: [User!]!\n}\n\n// user.graphql\ntype User {\n  id: ID!\n  name: String!\n}\n\n// app.js\nimport typeDefs from './schema.graphql';\nconsole.log(typeDefs); // prints the resolved schema string","lang":"javascript","description":"Configures webpack to resolve GraphQL import statements and use the resulting string in JavaScript."},"warnings":[{"fix":"Use @graphql-tools/load and @graphql-tools/graphql-file-loader or use raw-loader with graphql-import directly.","message":"This package is deprecated and the repository is archived. It relies on graphql-import, which is also deprecated.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Ensure all import paths are relative or use webpack resolve.alias.","message":"The loader only resolves imports relative to the importing file; it does not resolve from node_modules or aliases unless configured.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Add a declaration file: declare module '*.graphql' { const content: string; export default content; }","message":"TypeScript users need a module declaration for *.graphql files; otherwise TypeScript will not recognize the import.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'/graphql-file-loader':66 '/load':61 '/type.graphql':20 '0.2.1':26 '2018':30 'altern':47 'archiv':38 'current':24 'deprec':44 'direct':52 'e.g':16 'ecosystem':46 'file':23 'graphcool':45 'graphql':2,9,13,22,50,59,64,77 'graphql-import':8,49 'graphql-import-load':1 'graphql-tool':58,63 'import':3,10,14,17,51,71,78 'javascript':76 'last':27 'loader':4,6,56,68,80 'modul':81 'packag':32 'part':41 'raw':55 'raw-load':54 'repositori':36 'resolv':12 'return':69 'schema':72 'statement':15 'string':75 'tool':60,65 'type':18 'typescript':82 'unmaintain':34 'updat':28 'use':48 'version':25 'webpack':5,79","created_at":"2026-06-07T16:53:47.958937+00:00","updated_at":"2026-06-07T16:53:47.958937+00:00","problems":[{"fix":"Add the loader rule as shown in the quickstart. Ensure the test matches .graphql and the exclude is correct.","cause":"Webpack is not configured to use graphql-import-loader for .graphql files.","error":"Module parse failed: Unexpected token (1:0)\nYou may need an appropriate loader to handle this file type."},{"fix":"npm install --save-dev graphql-import","cause":"graphql-import is a peer dependency not explicitly listed; it must be installed.","error":"Error: Cannot find module 'graphql-import'"},{"fix":"Check the relative path and ensure the source file exists. The import paths are relative to the current file.","cause":"The import path in the .graphql file is incorrect or the file doesn't exist.","error":"Cannot find module './some.graphql'"}],"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/graphcool/graphql-import-loader","github":"https://github.com/graphcool/graphql-import-loader","docs":null,"changelog":null,"pypi":null,"npm":"graphql-import-loader","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}}