{"id":47201,"library":"bun-graphql-loader","title":"bun-graphql-loader","description":"A Bun plugin for loading GraphQL (.gql, .graphql) files, using graphql-tag for parsing. It allows importing GraphQL documents directly in Bun projects, supporting named queries and fragments. Version 1.0.3 is stable and actively maintained. Unlike Vite plugins, this is tailored for Bun's plugin system. It requires Bun (>=0.6.0) and graphql-tag as a peer dependency. Ship with TypeScript declarations.","status":"active","version":"1.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/0x31/bun-graphql-loader","tags":["javascript","bun","bun-plugin","graphql","graphql-tag","typescript"],"install":[{"cmd":"npm install bun-graphql-loader","lang":"bash","label":"npm"},{"cmd":"yarn add bun-graphql-loader","lang":"bash","label":"yarn"},{"cmd":"pnpm add bun-graphql-loader","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default export, ESM only. CommonJS require will fail.","wrong":"const bunGraphqlLoader = require('bun-graphql-loader')","symbol":"bunGraphqlLoader","correct":"import bunGraphqlLoader from 'bun-graphql-loader'"},{"note":"plugin is a named export from the 'bun' runtime package, not from this plugin.","wrong":"import plugin from 'bun-plugin'","symbol":"plugin","correct":"import { plugin } from 'bun'"},{"note":"If the file has a single query, use default import. Named imports are for multiple queries.","wrong":"import { ExampleQuery } from './example.gql'","symbol":"ExampleQuery","correct":"import ExampleQuery from './example.gql'"}],"quickstart":{"code":"// Loader plugin for Bun\nimport bunGraphqlLoader from 'bun-graphql-loader';\n\nawait Bun.build({\n  entrypoints: ['./src/index.ts'],\n  outdir: './dist',\n  plugins: [bunGraphqlLoader()],\n});\n\n// For bun test, preload the plugin\n// create bunGraphqlLoader.ts:\nimport { plugin } from 'bun';\nimport bunGraphqlLoader from 'bun-graphql-loader';\nplugin(bunGraphqlLoader());\n\n// In bunfig.toml:\n// [test]\n// preload = ['./bunGraphqlLoader.ts']\n\n// Then import GraphQL files\nimport query, { queries, fragments } from './schema.graphql';\nconsole.log(query); // DocumentNode","lang":"typescript","description":"Shows how to install, configure, and use the loader in Bun.build and bun test, with TypeScript imports."},"warnings":[{"fix":"Use import syntax instead of require().","message":"require() not supported; ESM-only plugin","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Use import Document, { _queries, _fragments } from './file.gql' to access all documents.","message":"Multiple queries/fragments must be imported via named exports (_queries, _fragments) or use the default export for single query","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Add 'declare module \"*.gql\"; declare module \"*.graphql\";' or a more specific type declaration.","message":"TypeScript requires a module declaration for .gql/.graphql files","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Install graphql-tag with 'bun add graphql-tag' or 'npm install graphql-tag'.","message":"graphql-tag peer dependency must be installed separately","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Call bunGraphqlLoader() inside the plugins array at build time.","message":"Plugin must be registered before building; lazy loading not supported","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Create a preload file that calls plugin(bunGraphqlLoader()) and reference it in [test].preload.","message":"Using plugin with bun test requires preload configuration in bunfig.toml","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'0.6.0':55 '1.0.3':35 'activ':39 'allow':21 'bun':2,6,27,48,54,69,71 'bun-graphql-load':1 'bun-plugin':70 'declar':67 'depend':63 'direct':25 'document':24 'file':13 'fragment':33 'gql':11 'graphql':3,10,12,16,23,58,73,75 'graphql-tag':15,57,74 'import':22 'javascript':68 'load':9 'loader':4 'maintain':40 'name':30 'pars':19 'peer':62 'plugin':7,43,50,72 'project':28 'queri':31 'requir':53 'ship':64 'stabl':37 'support':29 'system':51 'tag':17,59,76 'tailor':46 'typescript':66,77 'unlik':41 'use':14 'version':34 'vite':42","created_at":"2026-06-07T16:50:18.776536+00:00","updated_at":"2026-06-07T16:50:18.776536+00:00","problems":[{"fix":"Run 'bun add --dev bun-graphql-loader'","cause":"Package not installed","error":"Module not found: Can't resolve 'bun-graphql-loader'"},{"fix":"Use 'import bunGraphqlLoader from \"bun-graphql-loader\"'","cause":"Using require() instead of import","error":"require is not defined in ES module scope"},{"fix":"Run 'bun add graphql-tag'","cause":"Missing peer dependency graphql-tag","error":"Cannot find module 'graphql-tag'"},{"fix":"Add bunGraphqlLoader() to the plugins array in Bun.build or use plugin() for test","cause":"Plugin not registered before build","error":"No such plugin loader for file extension .gql"},{"fix":"Create a .d.ts file with 'declare module \"*.gql\";'","cause":"Missing type declaration for .gql files","error":"TypeScript error: Cannot find module './schema.gql' or its corresponding type declarations."}],"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/0x31/bun-graphql-loader","github":"https://github.com/0x31/bun-graphql-loader","docs":null,"changelog":null,"pypi":null,"npm":"bun-graphql-loader","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing","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}}