vite-plugin-graphql-codegen

所属分类:自动编程
开发工具:TypeScript
文件大小:122KB
下载次数:0
上传日期:2023-05-25 14:52:46
上 传 者sh-1993
说明:  Zero-config vite插件使用vite文件观察器以编程方式运行graphql代码生成,而无需安装...
(Zero-config vite plugin that uses the vite file watcher to run graphql codegen programmatically without needing to start a separate watcher)

文件列表:
.editorconfig (250, 2023-07-29)
.eslintrc.cjs (359, 2023-07-29)
.nvmrc (8, 2023-07-29)
.prettierrc (52, 2023-07-29)
CHANGELOG.md (10108, 2023-07-29)
LICENSE (1068, 2023-07-29)
package-lock.json (478514, 2023-07-29)
package.json (2435, 2023-07-29)
src (0, 2023-07-29)
src\index.ts (6313, 2023-07-29)
src\utils (0, 2023-07-29)
src\utils\debugLog.ts (293, 2023-07-29)
src\utils\fileMatchers.ts (1468, 2023-07-29)
src\utils\viteModes.ts (387, 2023-07-29)
test (0, 2023-07-29)
test\codegen-config-file (0, 2023-07-29)
test\codegen-config-file\__snapshots__ (0, 2023-07-29)
test\codegen-config-file\__snapshots__\codegen-config-file.spec.ts.snap (873, 2023-07-29)
test\codegen-config-file\codegen-config-file.spec.ts (1041, 2023-07-29)
test\codegen-config-file\codegen.yml (233, 2023-07-29)
test\codegen-config-file\graphql (0, 2023-07-29)
test\codegen-config-file\graphql\queries (0, 2023-07-29)
test\codegen-config-file\graphql\queries\Foo.graphql (20, 2023-07-29)
test\codegen-config-file\schema.graphql (29, 2023-07-29)
test\graphql-config-file (0, 2023-07-29)
test\graphql-config-file\__snapshots__ (0, 2023-07-29)
test\graphql-config-file\__snapshots__\graphql-config-file.spec.ts.snap (873, 2023-07-29)
test\graphql-config-file\graphql-config-file.spec.ts (1048, 2023-07-29)
test\graphql-config-file\graphql.config.yml (276, 2023-07-29)
test\graphql-config-file\graphql (0, 2023-07-29)
test\graphql-config-file\graphql\queries (0, 2023-07-29)
test\graphql-config-file\graphql\queries\Foo.graphql (20, 2023-07-29)
test\graphql-config-file\schema.graphql (29, 2023-07-29)
test\inline-config (0, 2023-07-29)
... ...

# Vite Plugin GraphQL Codegen Zero-config vite plugin that uses the vite file watcher to run [graphql codegen](https://www.graphql-code-generator.com/) programmatically without needing to start a separate watcher. ## Setup GraphQL Codegen Installation instructions found [here](https://www.graphql-code-generator.com/docs/getting-started/installation). Optional if already set up in project. ## Install Plugin ```bash # npm npm i -D vite-plugin-graphql-codegen # yarn yarn add -D vite-plugin-graphql-codegen # pnpm pnpm i -D vite-plugin-graphql-codegen ``` ## Initialize Plugin ```ts // 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. ```ts codegen({ /** * Run codegen on server start. * * @defaultValue `true` */ runOnStart?: boolean; /** * Run codegen on build. Will prevent build if codegen fails. * * @defaultValue `true` */ runOnBuild?: boolean; /** * Enable codegen integration with vite file watcher. * * @defaultValue `true` */ enableWatcher?: boolean; /** * Throw an error if codegen fails on server start. * * @defaultValue `false` */ throwOnStart?: boolean; /** * Throw an error if codegen fails on build. * * @defaultValue `true` */ throwOnBuild?: boolean; /** * Run codegen when a document matches. * * @defaultValue `true` */ matchOnDocuments?: boolean; /** * Run codegen when a schema matches. Only supports file path based schemas. * * @defaultValue `false` */ matchOnSchemas?: boolean; /** * Manually define the codegen config. */ config?: CodegenConfig; /** * Override parts of the codegen config just for this plugin. */ configOverride?: Partial; /** * Override parts of the codegen config just for this plugin on server start. */ configOverrideOnStart?: Partial; /** * Override parts of the codegen config just for this plugin on build. */ configOverrideOnBuild?: Partial; /** * Override parts of the codegen config just for this plugin in the watcher. */ configOverrideWatcher?: Partial; /** * Override the codegen config file path. */ configFilePathOverride?: string; /** * Log various steps to aid in tracking down bugs. * * @defaultValue `false` */ debug?: boolean; }); ```

近期下载者

相关文件


收藏者