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.
npm install bun-graphql-loaderNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to install, configure, and use the loader in Bun.build and bun test, with TypeScript imports.
Use import syntax instead of require().
Use import Document, { _queries, _fragments } from './file.gql' to access all documents.Add 'declare module "*.gql"; declare module "*.graphql";' or a more specific type declaration.
Install graphql-tag with 'bun add graphql-tag' or 'npm install graphql-tag'.
Call bunGraphqlLoader() inside the plugins array at build time.
Create a preload file that calls plugin(bunGraphqlLoader()) and reference it in [test].preload.
Run 'bun add --dev bun-graphql-loader'
Use 'import bunGraphqlLoader from "bun-graphql-loader"'
Run 'bun add graphql-tag'
Add bunGraphqlLoader() to the plugins array in Bun.build or use plugin() for test
Create a .d.ts file with 'declare module "*.gql";'
No dependency data recorded yet.