Skip to content

shellicar/build-graphql

Repository files navigation

@shellicar/build-graphql

npm package build status

Build plugin that loads GraphQL files and makes them available through a virtual module import.

  • ⚡️ Supports Vite, Webpack, Rspack, Vue CLI, Rollup, esbuild and more, powered by unplugin.

Installation & Quick Start

npm i --save @shellicar/build-graphql
pnpm add @shellicar/build-graphql
// build.ts
import GraphQLPlugin from '@shellicar/build-graphql/esbuild'

await build({
  // other options
  plugins: [
    GraphQLPlugin({ 
      globPattern: 'src/**/*.graphql'
    })
  ]
})
// vite.config.ts
import GraphQLPlugin from '@shellicar/build-graphql/vite'

export default defineConfig({
  // other options
  plugins: [
    GraphQLPlugin({ 
      globPattern: 'src/**/*.graphql'
    })
  ],
});
// main.ts
import typedefs from '@shellicar/build-graphql/typedefs'

@shellicar TypeScript Ecosystem

Core Libraries

Build Tools

  • @shellicar/build-version - Build plugin that calculates and exposes version information through a virtual module import.
  • @shellicar/build-graphql - Build plugin that loads GraphQL files and makes them available through a virtual module import.

Framework Adapters

Logging & Monitoring

Usage

pnpm add -D @shellicar/build-graphql

With esbuild

import graphqlPlugin from '@shellicar/build-graphql/esbuild';
import type { Options } from '@shellicar/build-graphql/types';
import { build } from 'esbuild';

const options: Options = {
  globPattern: '../**/*.graphql',
  debug: true,
};

await build({
  entryPoints: ['src/main.ts'],
  outdir: 'dist',
  bundle: true,
  platform: 'node',
  target: 'node20',
  tsconfig: 'tsconfig.json',
  plugins: [graphqlPlugin(options)],
});

With Vite

Importing GraphQL Documents

import typedefs from '@shellicar/build-graphql/typedefs'

See examples for full working implementations.

Options

See types.ts for detailed options documentation.

Credits

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published