Skip to content
This repository was archived by the owner on Aug 24, 2022. It is now read-only.

Zero-config vite plugin that uses the vite file watcher to run graphql codegen programmatically without needing to start a separate watcher

License

Notifications You must be signed in to change notification settings

stagnationlab/vite-plugin-graphql-codegen

This branch is 1 commit ahead of, 172 commits behind danielwaltz/vite-plugin-graphql-codegen:main.

Folders and files

NameName
Last commit message
Last commit date
Feb 1, 2022
Apr 21, 2022
Aug 21, 2021
Feb 9, 2022
Mar 18, 2022
Aug 21, 2021
Mar 18, 2022
Mar 18, 2022
Aug 21, 2021
Feb 23, 2022

Repository files navigation

Vite Plugin GraphQL Codegen

Zero-config vite plugin that uses the vite file watcher to run graphql codegen programmatically without needing to start a separate watcher.

Setup GraphQL Codegen

Installation instructions found here. Optional if already set up in project.

Install Plugin

# npm
npm i -D vite-plugin-graphql-codegen

# yarn
yarn add -D vite-plugin-graphql-codegen

Initialize Plugin

# vite.config.ts

import { defineConfig } from 'vite';
import codegen from 'vite-plugin-graphql-codegen';

export default defineConfig({
  plugins: [
    codegen()
  ],
});

Options

Providing options is not required as sensible defaults are in place, but there may be times where it's helpful to disable codegen under certain circumstances, like when running builds in CI.

codegen({
  /* Should codegen run when the dev server starts. Defaults to true. */
  runOnStart: true,
  /* Should codegen run on build. Will prevent build if codegen fails. Defaults to true. */
  runOnBuild: true,
  /* Should codegen run when files get added or change. Defaults to true. */
  enableWatcher: true,
  /* Allows manually defining the codegen config instead of relying on cosmiconfig. */
  config: CodegenConfig,
  /* Allows overriding codegen configuration options in the context of this plugin. Useful if you prefer a cleaner log by passing { errorsOnly: true }. */
  configOverride: CodegenConfig,
  /* Allows overriding the codegen configuration file path. */
  configFilePathOverride: `${process.cwd()}/codegen.yml`,
  /* Enable plugin logging to assist in debugging. Defaults to false. */
  debug: false,
})

Project bootstrapped with TSDX.

About

Zero-config vite plugin that uses the vite file watcher to run graphql codegen programmatically without needing to start a separate watcher

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 100.0%