├── .node-version ├── .gitignore ├── .vscode └── settings.json ├── test ├── codegen-config-file │ ├── schema.graphql │ ├── graphql │ │ └── queries │ │ │ └── Foo.graphql │ ├── codegen.yml │ ├── codegen-config-file.spec.ts │ └── __snapshots__ │ │ └── codegen-config-file.spec.ts.snap ├── graphql-config-file │ ├── schema.graphql │ ├── graphql │ │ └── queries │ │ │ └── Foo.graphql │ ├── graphql.config.yml │ ├── graphql-config-file.spec.ts │ └── __snapshots__ │ │ └── graphql-config-file.spec.ts.snap ├── graphql-multi-project │ ├── schema.graphql │ ├── graphql │ │ └── queries │ │ │ └── Foo.graphql │ ├── graphql.config.yml │ ├── graphql-multi-project.spec.ts │ └── __snapshots__ │ │ └── graphql-multi-project.spec.ts.snap ├── main │ ├── schema.graphql │ ├── codegen.yml │ ├── main.spec.ts │ └── __snapshots__ │ │ └── main.spec.ts.snap ├── match-on-schema │ ├── codegen.yml │ ├── __snapshots__ │ │ └── match-on-schema.spec.ts.snap │ └── match-on-schema.spec.ts ├── watch-outside-cwd │ ├── vite-root │ │ └── codegen.yml │ ├── __snapshots__ │ │ └── watch-outside-cwd.spec.ts.snap │ └── watch-outside-cwd.spec.ts ├── match-on-glob-schema │ ├── codegen.yml │ ├── __snapshots__ │ │ └── match-on-glob-schema.spec.ts.snap │ └── match-on-glob-schema.spec.ts └── inline-config │ ├── __snapshots__ │ └── inline-config.spec.ts.snap │ └── inline-config.spec.ts ├── eslint.config.ts ├── .editorconfig ├── tsconfig.json ├── vitest.config.ts ├── src ├── utils │ ├── debugLog.ts │ ├── viteModes.ts │ ├── fileMatchers.ts │ ├── matchCache.ts │ └── configPaths.ts └── index.ts ├── LICENSE ├── .github └── workflows │ └── main.yml ├── release.config.cjs ├── package.json ├── README.md └── CHANGELOG.md /.node-version: -------------------------------------------------------------------------------- 1 | 22.17.0 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | .DS_Store 3 | node_modules 4 | dist 5 | playground* 6 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "conventionalCommits.scopes": ["deps"] 3 | } 4 | -------------------------------------------------------------------------------- /test/codegen-config-file/schema.graphql: -------------------------------------------------------------------------------- 1 | type Query { 2 | foo: String 3 | } 4 | -------------------------------------------------------------------------------- /test/graphql-config-file/schema.graphql: -------------------------------------------------------------------------------- 1 | type Query { 2 | foo: String 3 | } 4 | -------------------------------------------------------------------------------- /test/graphql-multi-project/schema.graphql: -------------------------------------------------------------------------------- 1 | type Query { 2 | foo: String 3 | } 4 | -------------------------------------------------------------------------------- /test/main/schema.graphql: -------------------------------------------------------------------------------- 1 | type Query { 2 | foo: String 3 | bar: Int 4 | } 5 | -------------------------------------------------------------------------------- /test/codegen-config-file/graphql/queries/Foo.graphql: -------------------------------------------------------------------------------- 1 | query Foo { 2 | foo 3 | } 4 | -------------------------------------------------------------------------------- /test/graphql-config-file/graphql/queries/Foo.graphql: -------------------------------------------------------------------------------- 1 | query Foo { 2 | foo 3 | } 4 | -------------------------------------------------------------------------------- /test/graphql-multi-project/graphql/queries/Foo.graphql: -------------------------------------------------------------------------------- 1 | query Foo { 2 | foo 3 | } 4 | -------------------------------------------------------------------------------- /eslint.config.ts: -------------------------------------------------------------------------------- 1 | import { danielwaltz } from "@danielwaltz/eslint-config"; 2 | 3 | export default danielwaltz(); 4 | -------------------------------------------------------------------------------- /test/main/codegen.yml: -------------------------------------------------------------------------------- 1 | schema: ./test/main/schema.graphql 2 | documents: ./test/main/graphql/**/*.graphql 3 | generates: 4 | ./test/main/generated/graphql.ts: 5 | plugins: 6 | - typescript 7 | - typescript-operations 8 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | max_line_length = 80 12 | -------------------------------------------------------------------------------- /test/match-on-schema/codegen.yml: -------------------------------------------------------------------------------- 1 | schema: ./test/match-on-schema/schema.graphql 2 | documents: ./test/match-on-schema/graphql/**/*.graphql 3 | generates: 4 | ./test/match-on-schema/generated/graphql.ts: 5 | plugins: 6 | - typescript 7 | - typescript-operations 8 | -------------------------------------------------------------------------------- /test/codegen-config-file/codegen.yml: -------------------------------------------------------------------------------- 1 | schema: ./test/codegen-config-file/schema.graphql 2 | documents: ./test/codegen-config-file/graphql/**/*.graphql 3 | generates: 4 | ./test/codegen-config-file/generated/graphql.ts: 5 | plugins: 6 | - typescript 7 | - typescript-operations 8 | -------------------------------------------------------------------------------- /test/watch-outside-cwd/vite-root/codegen.yml: -------------------------------------------------------------------------------- 1 | schema: ./test/watch-outside-cwd/schema.graphql 2 | documents: ./test/watch-outside-cwd/vite-root/graphql/**/*.graphql 3 | generates: 4 | ./test/watch-outside-cwd/vite-root/generated/graphql.ts: 5 | plugins: 6 | - typescript 7 | - typescript-operations 8 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "module": "ESNext", 5 | "moduleResolution": "Bundler", 6 | "strict": true, 7 | "noEmit": true, 8 | "esModuleInterop": true, 9 | "skipLibCheck": true 10 | }, 11 | "include": ["src", "*.config.ts"] 12 | } 13 | -------------------------------------------------------------------------------- /vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { fileURLToPath, URL } from "node:url"; 2 | import { defineConfig } from "vitest/config"; 3 | 4 | export default defineConfig({ 5 | test: { 6 | testTimeout: 10000, 7 | }, 8 | resolve: { 9 | alias: { 10 | "@": fileURLToPath(new URL("./src", import.meta.url)), 11 | }, 12 | }, 13 | }); 14 | -------------------------------------------------------------------------------- /test/graphql-config-file/graphql.config.yml: -------------------------------------------------------------------------------- 1 | schema: ./test/graphql-config-file/schema.graphql 2 | documents: ./test/graphql-config-file/graphql/**/*.graphql 3 | extensions: 4 | codegen: 5 | generates: 6 | ./test/graphql-config-file/generated/graphql.ts: 7 | plugins: 8 | - typescript 9 | - typescript-operations 10 | -------------------------------------------------------------------------------- /test/match-on-glob-schema/codegen.yml: -------------------------------------------------------------------------------- 1 | schema: 2 | - ./test/match-on-glob-schema/dir-1/**/*.graphql 3 | - ./test/match-on-glob-schema/dir-2/**/*.graphql 4 | documents: ./test/match-on-glob-schema/graphql/**/*.graphql 5 | generates: 6 | ./test/match-on-glob-schema/generated/graphql.ts: 7 | plugins: 8 | - typescript 9 | - typescript-operations 10 | -------------------------------------------------------------------------------- /src/utils/debugLog.ts: -------------------------------------------------------------------------------- 1 | const RESET = "\u001B[0m"; 2 | const BRIGHT = "\u001B[1m"; 3 | const DIM = "\u001B[2m"; 4 | const FG_CYAN = "\u001B[36m"; 5 | 6 | const LOG_PREFIX = 7 | `${FG_CYAN}${BRIGHT}VITE PLUGIN GRAPHQL CODEGEN${RESET} ` as const; 8 | 9 | export function debugLog(...args: unknown[]) { 10 | // eslint-disable-next-line no-console 11 | console.log(LOG_PREFIX, DIM, ...args, RESET); 12 | } 13 | -------------------------------------------------------------------------------- /test/graphql-multi-project/graphql.config.yml: -------------------------------------------------------------------------------- 1 | projects: 2 | foo: 3 | schema: ./test/graphql-multi-project/schema.graphql 4 | documents: ./test/graphql-multi-project/graphql/**/*.graphql 5 | extensions: 6 | codegen: 7 | generates: 8 | ./test/graphql-multi-project/generated/graphql.ts: 9 | plugins: 10 | - typescript 11 | - typescript-operations 12 | -------------------------------------------------------------------------------- /src/utils/viteModes.ts: -------------------------------------------------------------------------------- 1 | import type { ConfigEnv } from "vite"; 2 | 3 | export type ViteMode = ConfigEnv["command"]; 4 | 5 | const modes: { [K in ViteMode]: K } = { 6 | serve: "serve", 7 | build: "build", 8 | }; 9 | 10 | const { serve, build } = modes; 11 | 12 | export function isServeMode(mode: ViteMode): mode is typeof serve { 13 | return mode === serve; 14 | } 15 | 16 | export function isBuildMode(mode: ViteMode): mode is typeof build { 17 | return mode === build; 18 | } 19 | -------------------------------------------------------------------------------- /src/utils/fileMatchers.ts: -------------------------------------------------------------------------------- 1 | import { normalizePath } from "vite"; 2 | import { getGeneratesPaths } from "./configPaths"; 3 | import type { CodegenContext } from "@graphql-codegen/cli"; 4 | 5 | export function isCodegenConfig(filePath: string, context: CodegenContext) { 6 | if (!context.filepath) return false; 7 | 8 | return normalizePath(filePath) === normalizePath(context.filepath); 9 | } 10 | 11 | export function isGeneratedFile(filePath: string, context: CodegenContext) { 12 | const generatesPaths = getGeneratesPaths(context); 13 | 14 | const normalizedFilePath = normalizePath(filePath); 15 | 16 | return generatesPaths.some((path) => normalizedFilePath.includes(path)); 17 | } 18 | -------------------------------------------------------------------------------- /src/utils/matchCache.ts: -------------------------------------------------------------------------------- 1 | import { normalizePath } from "vite"; 2 | import type { Options } from ".."; 3 | import { getDocumentPaths, getSchemaPaths } from "./configPaths"; 4 | import type { CodegenContext } from "@graphql-codegen/cli"; 5 | 6 | export function createMatchCache( 7 | context: CodegenContext, 8 | options: Pick, "matchOnDocuments" | "matchOnSchemas">, 9 | ) { 10 | const cache = new Set(); 11 | 12 | const refresh = async () => { 13 | const matchers = [] as Promise[]; 14 | if (options.matchOnDocuments) matchers.push(getDocumentPaths(context)); 15 | if (options.matchOnSchemas) matchers.push(getSchemaPaths(context)); 16 | 17 | const results = await Promise.all(matchers); 18 | 19 | const entries = results.flat().map(normalizePath); 20 | 21 | cache.clear(); 22 | 23 | for (const entry of entries) { 24 | cache.add(entry); 25 | } 26 | }; 27 | 28 | return { 29 | init: refresh, 30 | refresh, 31 | has: (filePath: string) => cache.has(normalizePath(filePath)), 32 | entries: () => Array.from(cache), 33 | }; 34 | } 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Daniel Waltz 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: [push, pull_request, workflow_dispatch] 3 | jobs: 4 | test: 5 | runs-on: ubuntu-latest 6 | steps: 7 | - uses: actions/checkout@v4 8 | - uses: actions/setup-node@v4 9 | with: 10 | node-version-file: .node-version 11 | cache: npm 12 | - run: npm ci 13 | - run: npm run lint 14 | - run: npm run type-check 15 | # - run: npm run test 16 | - run: npm run build 17 | - run: npx publint@latest 18 | - run: npx @arethetypeswrong/cli@latest --pack 19 | release: 20 | runs-on: ubuntu-latest 21 | needs: test 22 | permissions: write-all 23 | steps: 24 | - uses: actions/checkout@v4 25 | with: 26 | fetch-depth: 0 27 | token: ${{ secrets.GITHUB_TOKEN }} 28 | - uses: actions/setup-node@v4 29 | with: 30 | node-version-file: .node-version 31 | cache: npm 32 | - run: npm i -g npm@latest 33 | - run: npm ci 34 | - run: npm run semantic-release 35 | env: 36 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 37 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 38 | -------------------------------------------------------------------------------- /test/codegen-config-file/codegen-config-file.spec.ts: -------------------------------------------------------------------------------- 1 | import { promises as fs } from "node:fs"; 2 | import { createServer, type UserConfig, type ViteDevServer } from "vite"; 3 | import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest"; 4 | import codegen from "../../src/index"; 5 | 6 | const TEST_PATH = "./test/codegen-config-file" as const; 7 | const OUTPUT_PATH = `${TEST_PATH}/generated` as const; 8 | const OUTPUT_FILE = `${OUTPUT_PATH}/graphql.ts` as const; 9 | 10 | const viteConfig = { 11 | root: import.meta.dirname, 12 | plugins: [ 13 | codegen({ 14 | configFilePathOverride: `${TEST_PATH}/codegen.yml`, 15 | }), 16 | ], 17 | } satisfies UserConfig; 18 | 19 | describe("codegen-config-file", () => { 20 | let viteServer: ViteDevServer | null = null; 21 | 22 | beforeAll(async () => { 23 | viteServer = await createServer(viteConfig).then((s) => s.listen()); 24 | }); 25 | 26 | afterAll(async () => { 27 | await viteServer?.close(); 28 | viteServer = null; 29 | }); 30 | 31 | afterEach(async () => { 32 | await fs.rm(OUTPUT_PATH, { recursive: true }); 33 | }); 34 | 35 | it("generates", async () => { 36 | await new Promise((resolve) => setTimeout(resolve, 200)); 37 | const file = await fs.readFile(OUTPUT_FILE, "utf-8"); 38 | 39 | expect(file).toMatchSnapshot(); 40 | }); 41 | }); 42 | -------------------------------------------------------------------------------- /test/graphql-config-file/graphql-config-file.spec.ts: -------------------------------------------------------------------------------- 1 | import { promises as fs } from "node:fs"; 2 | import { createServer, type UserConfig, type ViteDevServer } from "vite"; 3 | import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest"; 4 | import codegen from "../../src/index"; 5 | 6 | const TEST_PATH = "./test/graphql-config-file" as const; 7 | const OUTPUT_PATH = `${TEST_PATH}/generated` as const; 8 | const OUTPUT_FILE = `${OUTPUT_PATH}/graphql.ts` as const; 9 | 10 | const viteConfig = { 11 | root: import.meta.dirname, 12 | plugins: [ 13 | codegen({ 14 | configFilePathOverride: `${TEST_PATH}/graphql.config.yml`, 15 | }), 16 | ], 17 | } satisfies UserConfig; 18 | 19 | describe("graphql-config-file", () => { 20 | let viteServer: ViteDevServer | null = null; 21 | 22 | beforeAll(async () => { 23 | viteServer = await createServer(viteConfig).then((s) => s.listen()); 24 | }); 25 | 26 | afterAll(async () => { 27 | await viteServer?.close(); 28 | viteServer = null; 29 | }); 30 | 31 | afterEach(async () => { 32 | await fs.rm(OUTPUT_PATH, { recursive: true }); 33 | }); 34 | 35 | it("generates", async () => { 36 | await new Promise((resolve) => setTimeout(resolve, 200)); 37 | const file = await fs.readFile(OUTPUT_FILE, "utf-8"); 38 | 39 | expect(file).toMatchSnapshot(); 40 | }); 41 | }); 42 | -------------------------------------------------------------------------------- /test/inline-config/__snapshots__/inline-config.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html 2 | 3 | exports[`inline-config > generates 1`] = ` 4 | "export type Maybe = T | null; 5 | export type InputMaybe = Maybe; 6 | export type Exact = { [K in keyof T]: T[K] }; 7 | export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; 8 | export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; 9 | export type MakeEmpty = { [_ in K]?: never }; 10 | export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; 11 | /** All built-in and custom scalars, mapped to their actual values */ 12 | export type Scalars = { 13 | ID: { input: string; output: string; } 14 | String: { input: string; output: string; } 15 | Boolean: { input: boolean; output: boolean; } 16 | Int: { input: number; output: number; } 17 | Float: { input: number; output: number; } 18 | }; 19 | 20 | export type Query = { 21 | __typename?: 'Query'; 22 | foo?: Maybe; 23 | }; 24 | 25 | export type FooQueryVariables = Exact<{ [key: string]: never; }>; 26 | 27 | 28 | export type FooQuery = { __typename?: 'Query', foo?: string | null }; 29 | " 30 | `; 31 | -------------------------------------------------------------------------------- /test/graphql-multi-project/graphql-multi-project.spec.ts: -------------------------------------------------------------------------------- 1 | import { promises as fs } from "node:fs"; 2 | import { createServer, type UserConfig, type ViteDevServer } from "vite"; 3 | import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest"; 4 | import codegen from "../../src/index"; 5 | 6 | const TEST_PATH = "./test/graphql-multi-project" as const; 7 | const OUTPUT_PATH = `${TEST_PATH}/generated` as const; 8 | const OUTPUT_FILE = `${OUTPUT_PATH}/graphql.ts` as const; 9 | 10 | const viteConfig = { 11 | root: import.meta.dirname, 12 | plugins: [ 13 | codegen({ 14 | configFilePathOverride: `${TEST_PATH}/graphql.config.yml`, 15 | project: "foo", 16 | }), 17 | ], 18 | } satisfies UserConfig; 19 | 20 | describe("graphql-multi-project", () => { 21 | let viteServer: ViteDevServer | null = null; 22 | 23 | beforeAll(async () => { 24 | viteServer = await createServer(viteConfig).then((s) => s.listen()); 25 | }); 26 | 27 | afterAll(async () => { 28 | await viteServer?.close(); 29 | viteServer = null; 30 | }); 31 | 32 | afterEach(async () => { 33 | await fs.rm(OUTPUT_PATH, { recursive: true }); 34 | }); 35 | 36 | it("generates", async () => { 37 | await new Promise((resolve) => setTimeout(resolve, 200)); 38 | const file = await fs.readFile(OUTPUT_FILE, "utf-8"); 39 | 40 | expect(file).toMatchSnapshot(); 41 | }); 42 | }); 43 | -------------------------------------------------------------------------------- /test/codegen-config-file/__snapshots__/codegen-config-file.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html 2 | 3 | exports[`codegen-config-file > generates 1`] = ` 4 | "export type Maybe = T | null; 5 | export type InputMaybe = Maybe; 6 | export type Exact = { [K in keyof T]: T[K] }; 7 | export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; 8 | export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; 9 | export type MakeEmpty = { [_ in K]?: never }; 10 | export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; 11 | /** All built-in and custom scalars, mapped to their actual values */ 12 | export type Scalars = { 13 | ID: { input: string; output: string; } 14 | String: { input: string; output: string; } 15 | Boolean: { input: boolean; output: boolean; } 16 | Int: { input: number; output: number; } 17 | Float: { input: number; output: number; } 18 | }; 19 | 20 | export type Query = { 21 | __typename?: 'Query'; 22 | foo?: Maybe; 23 | }; 24 | 25 | export type FooQueryVariables = Exact<{ [key: string]: never; }>; 26 | 27 | 28 | export type FooQuery = { __typename?: 'Query', foo?: string | null }; 29 | " 30 | `; 31 | -------------------------------------------------------------------------------- /test/graphql-config-file/__snapshots__/graphql-config-file.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html 2 | 3 | exports[`graphql-config-file > generates 1`] = ` 4 | "export type Maybe = T | null; 5 | export type InputMaybe = Maybe; 6 | export type Exact = { [K in keyof T]: T[K] }; 7 | export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; 8 | export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; 9 | export type MakeEmpty = { [_ in K]?: never }; 10 | export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; 11 | /** All built-in and custom scalars, mapped to their actual values */ 12 | export type Scalars = { 13 | ID: { input: string; output: string; } 14 | String: { input: string; output: string; } 15 | Boolean: { input: boolean; output: boolean; } 16 | Int: { input: number; output: number; } 17 | Float: { input: number; output: number; } 18 | }; 19 | 20 | export type Query = { 21 | __typename?: 'Query'; 22 | foo?: Maybe; 23 | }; 24 | 25 | export type FooQueryVariables = Exact<{ [key: string]: never; }>; 26 | 27 | 28 | export type FooQuery = { __typename?: 'Query', foo?: string | null }; 29 | " 30 | `; 31 | -------------------------------------------------------------------------------- /test/graphql-multi-project/__snapshots__/graphql-multi-project.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html 2 | 3 | exports[`graphql-multi-project > generates 1`] = ` 4 | "export type Maybe = T | null; 5 | export type InputMaybe = Maybe; 6 | export type Exact = { [K in keyof T]: T[K] }; 7 | export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; 8 | export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; 9 | export type MakeEmpty = { [_ in K]?: never }; 10 | export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; 11 | /** All built-in and custom scalars, mapped to their actual values */ 12 | export type Scalars = { 13 | ID: { input: string; output: string; } 14 | String: { input: string; output: string; } 15 | Boolean: { input: boolean; output: boolean; } 16 | Int: { input: number; output: number; } 17 | Float: { input: number; output: number; } 18 | }; 19 | 20 | export type Query = { 21 | __typename?: 'Query'; 22 | foo?: Maybe; 23 | }; 24 | 25 | export type FooQueryVariables = Exact<{ [key: string]: never; }>; 26 | 27 | 28 | export type FooQuery = { __typename?: 'Query', foo?: string | null }; 29 | " 30 | `; 31 | -------------------------------------------------------------------------------- /test/match-on-schema/__snapshots__/match-on-schema.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html 2 | 3 | exports[`match-on-schema > generates on schema change 1`] = ` 4 | "export type Maybe = T | null; 5 | export type InputMaybe = Maybe; 6 | export type Exact = { [K in keyof T]: T[K] }; 7 | export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; 8 | export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; 9 | export type MakeEmpty = { [_ in K]?: never }; 10 | export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; 11 | /** All built-in and custom scalars, mapped to their actual values */ 12 | export type Scalars = { 13 | ID: { input: string; output: string; } 14 | String: { input: string; output: string; } 15 | Boolean: { input: boolean; output: boolean; } 16 | Int: { input: number; output: number; } 17 | Float: { input: number; output: number; } 18 | }; 19 | 20 | export type Query = { 21 | __typename?: 'Query'; 22 | bar?: Maybe; 23 | foo?: Maybe; 24 | }; 25 | 26 | export type FooQueryVariables = Exact<{ [key: string]: never; }>; 27 | 28 | 29 | export type FooQuery = { __typename?: 'Query', foo?: string | null }; 30 | " 31 | `; 32 | -------------------------------------------------------------------------------- /test/watch-outside-cwd/__snapshots__/watch-outside-cwd.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html 2 | 3 | exports[`watch-outside-cwd > generates on schema change outside of cwd 1`] = ` 4 | "export type Maybe = T | null; 5 | export type InputMaybe = Maybe; 6 | export type Exact = { [K in keyof T]: T[K] }; 7 | export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; 8 | export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; 9 | export type MakeEmpty = { [_ in K]?: never }; 10 | export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; 11 | /** All built-in and custom scalars, mapped to their actual values */ 12 | export type Scalars = { 13 | ID: { input: string; output: string; } 14 | String: { input: string; output: string; } 15 | Boolean: { input: boolean; output: boolean; } 16 | Int: { input: number; output: number; } 17 | Float: { input: number; output: number; } 18 | }; 19 | 20 | export type Query = { 21 | __typename?: 'Query'; 22 | bar?: Maybe; 23 | foo?: Maybe; 24 | }; 25 | 26 | export type FooQueryVariables = Exact<{ [key: string]: never; }>; 27 | 28 | 29 | export type FooQuery = { __typename?: 'Query', foo?: string | null }; 30 | " 31 | `; 32 | -------------------------------------------------------------------------------- /test/match-on-glob-schema/__snapshots__/match-on-glob-schema.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html 2 | 3 | exports[`match-on-glob-schema > generates on schema change 1`] = ` 4 | "export type Maybe = T | null; 5 | export type InputMaybe = Maybe; 6 | export type Exact = { [K in keyof T]: T[K] }; 7 | export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; 8 | export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; 9 | export type MakeEmpty = { [_ in K]?: never }; 10 | export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; 11 | /** All built-in and custom scalars, mapped to their actual values */ 12 | export type Scalars = { 13 | ID: { input: string; output: string; } 14 | String: { input: string; output: string; } 15 | Boolean: { input: boolean; output: boolean; } 16 | Int: { input: number; output: number; } 17 | Float: { input: number; output: number; } 18 | }; 19 | 20 | export type Query = { 21 | __typename?: 'Query'; 22 | bar?: Maybe; 23 | baz?: Maybe; 24 | foo?: Maybe; 25 | qux?: Maybe; 26 | }; 27 | 28 | export type FooQueryVariables = Exact<{ [key: string]: never; }>; 29 | 30 | 31 | export type FooQuery = { __typename?: 'Query', foo?: number | null }; 32 | " 33 | `; 34 | -------------------------------------------------------------------------------- /test/inline-config/inline-config.spec.ts: -------------------------------------------------------------------------------- 1 | import { promises as fs } from "node:fs"; 2 | import { createServer, type UserConfig, type ViteDevServer } from "vite"; 3 | import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest"; 4 | import codegen, { type Options } from "../../src/index"; 5 | import type { CodegenConfig } from "@graphql-codegen/cli"; 6 | 7 | const TEST_PATH = "./test/inline-config" as const; 8 | const OUTPUT_PATH = `${TEST_PATH}/generated` as const; 9 | const OUTPUT_FILE = `${OUTPUT_PATH}/graphql.ts` as const; 10 | 11 | const codegenConfig = { 12 | schema: ` 13 | type Query { 14 | foo: String 15 | } 16 | `, 17 | documents: ` 18 | query Foo { 19 | foo 20 | } 21 | `, 22 | generates: { 23 | [OUTPUT_FILE]: { 24 | plugins: ["typescript", "typescript-operations"], 25 | }, 26 | }, 27 | } satisfies CodegenConfig; 28 | 29 | const pluginConfig = { 30 | config: codegenConfig, 31 | } satisfies Options; 32 | 33 | const viteConfig = { 34 | root: import.meta.dirname, 35 | plugins: [codegen(pluginConfig)], 36 | } satisfies UserConfig; 37 | 38 | describe("inline-config", () => { 39 | let viteServer: ViteDevServer | null = null; 40 | 41 | beforeAll(async () => { 42 | viteServer = await createServer(viteConfig).then((s) => s.listen()); 43 | }); 44 | 45 | afterAll(async () => { 46 | await viteServer?.close(); 47 | viteServer = null; 48 | }); 49 | 50 | afterEach(async () => { 51 | await fs.rm(OUTPUT_PATH, { recursive: true }); 52 | }); 53 | 54 | it("generates", async () => { 55 | await new Promise((resolve) => setTimeout(resolve, 200)); 56 | const file = await fs.readFile(OUTPUT_FILE, "utf-8"); 57 | 58 | expect(file).toMatchSnapshot(); 59 | }); 60 | }); 61 | -------------------------------------------------------------------------------- /src/utils/configPaths.ts: -------------------------------------------------------------------------------- 1 | import { normalizePath } from "vite"; 2 | import type { CodegenContext } from "@graphql-codegen/cli"; 3 | import type { Types } from "@graphql-codegen/plugin-helpers"; 4 | 5 | export async function getDocumentPaths( 6 | context: CodegenContext, 7 | ): Promise { 8 | const config = context.getConfig(); 9 | 10 | const sourceDocuments = Object.values(config.generates).map((output) => 11 | Array.isArray(output) ? undefined : output.documents, 12 | ); 13 | 14 | if (config.documents) { 15 | sourceDocuments.unshift(config.documents); 16 | } 17 | 18 | const normalized = sourceDocuments 19 | .filter((item) => item !== undefined) 20 | .flat(); 21 | 22 | if (!normalized.length) return []; 23 | 24 | const documents = await context.loadDocuments(normalized); 25 | 26 | if (!documents.length) return []; 27 | 28 | return documents 29 | .map(({ location = "" }) => location) 30 | .filter(Boolean) 31 | .map(normalizePath); 32 | } 33 | 34 | export async function getSchemaPaths( 35 | context: CodegenContext, 36 | ): Promise { 37 | const config = context.getConfig(); 38 | 39 | const sourceSchemas = Object.values(config.generates).map((output) => 40 | Array.isArray(output) ? undefined : output.schema, 41 | ); 42 | 43 | if (config.schema) { 44 | sourceSchemas.unshift(config.schema); 45 | } 46 | 47 | const normalized = sourceSchemas 48 | .filter((item): item is NonNullable => !!item) 49 | .flat(); 50 | 51 | if (!normalized.length) return []; 52 | 53 | const schemas = await context.loadSchema( 54 | // loadSchema supports array of string, but typings are wrong 55 | normalized as unknown as Types.Schema, 56 | ); 57 | 58 | return (schemas.extensions.sources as { name: string }[]) 59 | .map(({ name = "" }) => name) 60 | .filter(Boolean) 61 | .map(normalizePath); 62 | } 63 | 64 | export function getGeneratesPaths(context: CodegenContext): string[] { 65 | const config = context.getConfig(); 66 | 67 | return Object.keys(config.generates).map(normalizePath); 68 | } 69 | -------------------------------------------------------------------------------- /release.config.cjs: -------------------------------------------------------------------------------- 1 | /** @type {import('semantic-release').GlobalConfig} */ 2 | module.exports = { 3 | branches: ["main"], 4 | plugins: [ 5 | [ 6 | "@semantic-release/commit-analyzer", 7 | { 8 | preset: "conventionalcommits", 9 | releaseRules: [ 10 | { 11 | type: "chore", 12 | scope: "deps", 13 | release: "patch", 14 | }, 15 | ], 16 | }, 17 | ], 18 | [ 19 | "@semantic-release/release-notes-generator", 20 | { 21 | preset: "conventionalcommits", 22 | presetConfig: { 23 | types: [ 24 | { 25 | type: "feat", 26 | section: "Features", 27 | hidden: false, 28 | }, 29 | { 30 | type: "fix", 31 | section: "Bug Fixes", 32 | hidden: false, 33 | }, 34 | { 35 | type: "perf", 36 | section: "Performance Improvements", 37 | hidden: false, 38 | }, 39 | { 40 | type: "revert", 41 | section: "Reverts", 42 | hidden: false, 43 | }, 44 | { 45 | type: "docs", 46 | section: "Documentation", 47 | hidden: false, 48 | }, 49 | { 50 | type: "style", 51 | section: "Styles", 52 | hidden: false, 53 | }, 54 | { 55 | type: "chore", 56 | section: "Miscellaneous Chores", 57 | hidden: false, 58 | }, 59 | { 60 | type: "refactor", 61 | section: "Code Refactoring", 62 | hidden: false, 63 | }, 64 | { 65 | type: "test", 66 | section: "Tests", 67 | hidden: false, 68 | }, 69 | { 70 | type: "build", 71 | section: "Build System", 72 | hidden: false, 73 | }, 74 | { 75 | type: "ci", 76 | section: "Continuous Integration", 77 | hidden: false, 78 | }, 79 | ], 80 | }, 81 | }, 82 | ], 83 | "@semantic-release/changelog", 84 | "@semantic-release/npm", 85 | "@semantic-release/git", 86 | "@semantic-release/github", 87 | ], 88 | }; 89 | -------------------------------------------------------------------------------- /test/match-on-schema/match-on-schema.spec.ts: -------------------------------------------------------------------------------- 1 | import { promises as fs } from "node:fs"; 2 | import { createServer, type UserConfig, type ViteDevServer } from "vite"; 3 | import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest"; 4 | import codegen from "../../src/index"; 5 | 6 | const TEST_PATH = "./test/match-on-schema" as const; 7 | const SCHEMA_PATH = `${TEST_PATH}/schema.graphql` as const; 8 | const DOCUMENT_PATH = `${TEST_PATH}/graphql` as const; 9 | const OUTPUT_PATH = `${TEST_PATH}/generated` as const; 10 | const OUTPUT_FILE_NAME = "graphql.ts" as const; 11 | const OUTPUT_FILE = `${OUTPUT_PATH}/${OUTPUT_FILE_NAME}` as const; 12 | 13 | const viteConfig = { 14 | root: import.meta.dirname, 15 | plugins: [ 16 | codegen({ 17 | runOnStart: false, 18 | matchOnDocuments: false, 19 | matchOnSchemas: true, 20 | configFilePathOverride: `${TEST_PATH}/codegen.yml`, 21 | }), 22 | ], 23 | } satisfies UserConfig; 24 | 25 | describe("match-on-schema", () => { 26 | let viteServer: ViteDevServer | null = null; 27 | 28 | const isFileGenerated = async (): Promise => { 29 | try { 30 | await new Promise((resolve) => setTimeout(resolve, 200)); 31 | await fs.access(OUTPUT_FILE); 32 | return true; 33 | } catch { 34 | // ignore 35 | } 36 | 37 | return new Promise((resolve, reject) => { 38 | if (!viteServer) reject("Vite server not started"); 39 | 40 | viteServer?.watcher.on("add", (path: string) => { 41 | if (path.includes(OUTPUT_FILE_NAME)) resolve(true); 42 | }); 43 | 44 | setTimeout(() => reject("Generated file not found"), 5000); 45 | }); 46 | }; 47 | 48 | beforeAll(async () => { 49 | await fs.writeFile(SCHEMA_PATH, "type Query { foo: String }"); 50 | await fs.mkdir(DOCUMENT_PATH, { recursive: true }); 51 | await fs.writeFile(`${DOCUMENT_PATH}/Foo.graphql`, "query Foo { foo }"); 52 | viteServer = await createServer(viteConfig).then((s) => s.listen()); 53 | }); 54 | 55 | afterAll(async () => { 56 | await viteServer?.close(); 57 | viteServer = null; 58 | await fs.rm(SCHEMA_PATH, { recursive: true }); 59 | await fs.rm(DOCUMENT_PATH, { recursive: true }); 60 | }); 61 | 62 | afterEach(async () => { 63 | await fs.rm(OUTPUT_PATH, { recursive: true }); 64 | }); 65 | 66 | it("generates on schema change", async () => { 67 | await fs.writeFile(SCHEMA_PATH, "type Query { foo: String bar: Int }"); 68 | 69 | await isFileGenerated(); 70 | 71 | const file = await fs.readFile(OUTPUT_FILE, "utf-8"); 72 | 73 | expect(file).toMatchSnapshot(); 74 | }); 75 | }); 76 | -------------------------------------------------------------------------------- /test/watch-outside-cwd/watch-outside-cwd.spec.ts: -------------------------------------------------------------------------------- 1 | import { promises as fs } from "node:fs"; 2 | import { join } from "node:path"; 3 | import { createServer, type UserConfig, type ViteDevServer } from "vite"; 4 | import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest"; 5 | import codegen from "../../src/index"; 6 | 7 | const TEST_PATH = "./test/watch-outside-cwd" as const; 8 | const SCHEMA_PATH = `${TEST_PATH}/schema.graphql` as const; 9 | const DOCUMENT_PATH = `${TEST_PATH}/vite-root/graphql` as const; 10 | const OUTPUT_PATH = `${TEST_PATH}/vite-root/generated` as const; 11 | const OUTPUT_FILE_NAME = "graphql.ts" as const; 12 | const OUTPUT_FILE = `${OUTPUT_PATH}/${OUTPUT_FILE_NAME}` as const; 13 | 14 | const viteConfig = { 15 | root: join(import.meta.dirname, "./vite-root"), 16 | plugins: [ 17 | codegen({ 18 | runOnStart: false, 19 | matchOnDocuments: false, 20 | matchOnSchemas: true, 21 | watchCodegenConfigFiles: true, 22 | configFilePathOverride: `${TEST_PATH}/vite-root/codegen.yml`, 23 | }), 24 | ], 25 | } satisfies UserConfig; 26 | 27 | describe("watch-outside-cwd", () => { 28 | let viteServer: ViteDevServer | null = null; 29 | 30 | const isFileGenerated = async (): Promise => { 31 | try { 32 | await new Promise((resolve) => setTimeout(resolve, 200)); 33 | await fs.access(OUTPUT_FILE); 34 | return true; 35 | } catch { 36 | // ignore 37 | } 38 | 39 | return new Promise((resolve, reject) => { 40 | if (!viteServer) reject("Vite server not started"); 41 | 42 | viteServer?.watcher.on("add", (path: string) => { 43 | if (path.includes(OUTPUT_FILE_NAME)) resolve(true); 44 | }); 45 | 46 | setTimeout(() => reject("Generated file not found"), 5000); 47 | }); 48 | }; 49 | 50 | beforeAll(async () => { 51 | await fs.writeFile(SCHEMA_PATH, "type Query { foo: String }"); 52 | await fs.mkdir(DOCUMENT_PATH, { recursive: true }); 53 | await fs.writeFile(`${DOCUMENT_PATH}/Foo.graphql`, "query Foo { foo }"); 54 | viteServer = await createServer(viteConfig).then((s) => s.listen()); 55 | }); 56 | 57 | afterAll(async () => { 58 | await viteServer?.close(); 59 | viteServer = null; 60 | await fs.rm(SCHEMA_PATH, { recursive: true }); 61 | await fs.rm(DOCUMENT_PATH, { recursive: true }); 62 | }); 63 | 64 | afterEach(async () => { 65 | await fs.rm(OUTPUT_PATH, { recursive: true }); 66 | }); 67 | 68 | it("generates on schema change outside of cwd", async () => { 69 | await fs.writeFile(SCHEMA_PATH, "type Query { foo: String bar: Int }"); 70 | 71 | await isFileGenerated(); 72 | 73 | const file = await fs.readFile(OUTPUT_FILE, "utf-8"); 74 | 75 | expect(file).toMatchSnapshot(); 76 | }); 77 | }); 78 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vite-plugin-graphql-codegen", 3 | "version": "3.7.0", 4 | "description": "Zero-config vite plugin that uses the vite file watcher to run graphql codegen programmatically without needing to start a separate watcher", 5 | "type": "module", 6 | "keywords": [ 7 | "graphql", 8 | "codegen", 9 | "graphql-codegen", 10 | "graphql-code-generator", 11 | "vite", 12 | "vite-plugin", 13 | "vite-plugin-graphql-codegen" 14 | ], 15 | "license": "MIT", 16 | "repository": { 17 | "type": "git", 18 | "url": "git+https://github.com/danielwaltz/vite-plugin-graphql-codegen.git" 19 | }, 20 | "author": "Daniel Waltz", 21 | "files": [ 22 | "dist" 23 | ], 24 | "main": "./dist/index.cjs", 25 | "module": "./dist/index.mjs", 26 | "types": "./dist/index.d.ts", 27 | "exports": { 28 | ".": { 29 | "require": "./dist/index.cjs", 30 | "import": "./dist/index.mjs" 31 | } 32 | }, 33 | "publishConfig": { 34 | "access": "public", 35 | "provenance": true, 36 | "registry": "https://registry.npmjs.org/" 37 | }, 38 | "scripts": { 39 | "build": "unbuild", 40 | "stub": "unbuild --stub", 41 | "lint": "eslint --cache --cache-location ./node_modules/.cache/.eslintcache --max-warnings 0", 42 | "publint": "npx -y publint@latest && npx -y @arethetypeswrong/cli@latest --pack", 43 | "type-check": "tsc --noEmit", 44 | "test:unit": "vitest", 45 | "test:unit:run": "vitest run", 46 | "test": "run-s lint type-check build test:unit:run publint", 47 | "release": "standard-version", 48 | "semantic-release": "semantic-release", 49 | "prepack": "npm run build" 50 | }, 51 | "peerDependencies": { 52 | "@graphql-codegen/cli": ">=1.0.0 <7.0.0", 53 | "graphql": ">=14.0.0 <17.0.0", 54 | "vite": ">=2.7.0 <8.0.0" 55 | }, 56 | "devDependencies": { 57 | "@danielwaltz/eslint-config": "^2.6.0", 58 | "@graphql-codegen/plugin-helpers": "^6.0.0", 59 | "@graphql-codegen/typescript": "^5.0.0", 60 | "@graphql-codegen/typescript-operations": "^5.0.0", 61 | "@semantic-release/changelog": "^6.0.3", 62 | "@semantic-release/commit-analyzer": "^13.0.1", 63 | "@semantic-release/git": "^10.0.1", 64 | "@semantic-release/github": "^11.0.6", 65 | "@semantic-release/npm": "^12.0.2", 66 | "@semantic-release/release-notes-generator": "^14.1.0", 67 | "@types/node": "~22.17.2", 68 | "eslint": "^9.35.0", 69 | "graphql-tag": "^2.12.6", 70 | "jiti": "^2.5.1", 71 | "npm-run-all2": "^8.0.4", 72 | "prettier": "^3.6.2", 73 | "semantic-release": "^24.2.8", 74 | "standard-version": "^9.5.0", 75 | "typescript": "~5.9.2", 76 | "unbuild": "~3.4.2", 77 | "vite": "^7.1.5", 78 | "vitest": "^3.2.4" 79 | }, 80 | "overrides": { 81 | "conventional-changelog-conventionalcommits": ">=9.1.0" 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /test/main/main.spec.ts: -------------------------------------------------------------------------------- 1 | import { promises as fs } from "node:fs"; 2 | import { createServer, type UserConfig, type ViteDevServer } from "vite"; 3 | import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest"; 4 | import codegen from "../../src/index"; 5 | 6 | const TEST_PATH = "./test/main" as const; 7 | const DOCUMENT_PATH = `${TEST_PATH}/graphql` as const; 8 | const OUTPUT_PATH = `${TEST_PATH}/generated` as const; 9 | const OUTPUT_FILE_NAME = "graphql.ts" as const; 10 | const OUTPUT_FILE = `${OUTPUT_PATH}/${OUTPUT_FILE_NAME}` as const; 11 | 12 | const viteConfig = { 13 | root: import.meta.dirname, 14 | plugins: [ 15 | codegen({ 16 | configFilePathOverride: `${TEST_PATH}/codegen.yml`, 17 | }), 18 | ], 19 | } satisfies UserConfig; 20 | 21 | describe("main", () => { 22 | let viteServer: ViteDevServer | null = null; 23 | 24 | const isFileGenerated = async (): Promise => { 25 | try { 26 | await new Promise((resolve) => setTimeout(resolve, 200)); 27 | await fs.access(OUTPUT_FILE); 28 | return true; 29 | } catch { 30 | // ignore 31 | } 32 | 33 | return new Promise((resolve, reject) => { 34 | if (!viteServer) reject("Vite server not started"); 35 | 36 | viteServer?.watcher.on("add", (path: string) => { 37 | if (path.includes(OUTPUT_FILE_NAME)) resolve(true); 38 | }); 39 | 40 | setTimeout(() => reject("Generated file not found"), 5000); 41 | }); 42 | }; 43 | 44 | beforeAll(async () => { 45 | await fs.mkdir(DOCUMENT_PATH, { recursive: true }); 46 | await fs.writeFile(`${DOCUMENT_PATH}/Foo.graphql`, "query Foo { foo }"); 47 | viteServer = await createServer(viteConfig).then((s) => s.listen()); 48 | }); 49 | 50 | afterAll(async () => { 51 | await viteServer?.close(); 52 | viteServer = null; 53 | await fs.rm(DOCUMENT_PATH, { recursive: true }); 54 | }); 55 | 56 | afterEach(async () => { 57 | await fs.rm(OUTPUT_PATH, { recursive: true }); 58 | }); 59 | 60 | it("generates on server start", async () => { 61 | const file = await fs.readFile(OUTPUT_FILE, "utf-8"); 62 | 63 | expect(file).toMatchSnapshot(); 64 | }); 65 | 66 | it("generates on file add", async () => { 67 | const documentPath = `${DOCUMENT_PATH}/Bar.graphql`; 68 | 69 | await fs.writeFile(documentPath, "query Bar { bar }"); 70 | 71 | await isFileGenerated(); 72 | 73 | const file = await fs.readFile(OUTPUT_FILE, "utf-8"); 74 | 75 | expect(file).toMatchSnapshot(); 76 | }); 77 | 78 | it("generates on file change", async () => { 79 | const documentPath = `${DOCUMENT_PATH}/Foo.graphql`; 80 | 81 | await fs.writeFile(documentPath, "query Foo { foo bar }"); 82 | 83 | await isFileGenerated(); 84 | 85 | const file = await fs.readFile(OUTPUT_FILE, "utf-8"); 86 | 87 | expect(file).toMatchSnapshot(); 88 | }); 89 | }); 90 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Vite Plugin GraphQL Codegen [![npm](https://img.shields.io/npm/v/vite-plugin-graphql-codegen.svg)](https://npmjs.com/package/vite-plugin-graphql-codegen) 2 | 3 | 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. 4 | 5 | ## Setup GraphQL Codegen 6 | 7 | Installation instructions found [here](https://www.graphql-code-generator.com/docs/getting-started/installation). Optional if already set up in project. 8 | 9 | ## Install Plugin 10 | 11 | ```shell 12 | # npm 13 | npm i -D vite-plugin-graphql-codegen 14 | 15 | # yarn 16 | yarn add -D vite-plugin-graphql-codegen 17 | 18 | # pnpm 19 | pnpm i -D vite-plugin-graphql-codegen 20 | ``` 21 | 22 | ## Initialize Plugin 23 | 24 | ```ts 25 | // vite.config.ts 26 | 27 | import { defineConfig } from 'vite'; 28 | import codegen from 'vite-plugin-graphql-codegen'; 29 | 30 | export default defineConfig({ 31 | plugins: [ 32 | codegen(), 33 | ], 34 | }); 35 | ``` 36 | 37 | ## Options 38 | 39 | 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. 40 | 41 | ```ts 42 | codegen({ 43 | /** 44 | * Run codegen on server start. 45 | * 46 | * @default true 47 | */ 48 | runOnStart: boolean, 49 | /** 50 | * Run codegen on build. Will prevent build if codegen fails. 51 | * 52 | * @default true 53 | */ 54 | runOnBuild: boolean, 55 | /** 56 | * Enable codegen integration with vite file watcher. 57 | * 58 | * @default true 59 | */ 60 | enableWatcher: boolean, 61 | /** 62 | * Automatically add schemas and documents referenced in the codegen config 63 | * to the file watcher. 64 | * 65 | * @default true 66 | */ 67 | watchCodegenConfigFiles: boolean, 68 | /** 69 | * Throw an error if codegen fails on server start. 70 | * 71 | * @default false 72 | */ 73 | throwOnStart: boolean, 74 | /** 75 | * Throw an error if codegen fails on build. 76 | * 77 | * @default true 78 | */ 79 | throwOnBuild: boolean, 80 | /** 81 | * Run codegen when a document matches. 82 | * 83 | * @default true 84 | */ 85 | matchOnDocuments: boolean, 86 | /** 87 | * Run codegen when a schema matches. 88 | * 89 | * @default false 90 | */ 91 | matchOnSchemas: boolean, 92 | /** 93 | * Manually define the codegen config. 94 | */ 95 | config: CodegenConfig, 96 | /** 97 | * Override parts of the codegen config just for this plugin. 98 | */ 99 | configOverride: Partial, 100 | /** 101 | * Override parts of the codegen config just for this plugin on server start. 102 | */ 103 | configOverrideOnStart: Partial, 104 | /** 105 | * Override parts of the codegen config just for this plugin on build. 106 | */ 107 | configOverrideOnBuild: Partial, 108 | /** 109 | * Override parts of the codegen config just for this plugin in the watcher. 110 | */ 111 | configOverrideWatcher: Partial, 112 | /** 113 | * Override the codegen config file path. 114 | */ 115 | configFilePathOverride: string, 116 | /** 117 | * Log various steps to aid in tracking down bugs. 118 | * 119 | * @default false 120 | */ 121 | debug: boolean, 122 | }); 123 | ``` 124 | -------------------------------------------------------------------------------- /test/match-on-glob-schema/match-on-glob-schema.spec.ts: -------------------------------------------------------------------------------- 1 | import { promises as fs } from "node:fs"; 2 | import { createServer, type UserConfig, type ViteDevServer } from "vite"; 3 | import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest"; 4 | import codegen from "../../src/index"; 5 | 6 | const TEST_PATH = "./test/match-on-glob-schema" as const; 7 | const DIR_PATH_1 = `${TEST_PATH}/dir-1` as const; 8 | const DIR_PATH_2 = `${TEST_PATH}/dir-2` as const; 9 | const SCHEMA_PATH_1 = `${DIR_PATH_1}/schema-1.graphql` as const; 10 | const SCHEMA_PATH_2 = `${DIR_PATH_1}/schema-2.graphql` as const; 11 | const SCHEMA_PATH_3 = `${DIR_PATH_2}/schema-1.graphql` as const; 12 | const SCHEMA_PATH_4 = `${DIR_PATH_2}/schema-2.graphql` as const; 13 | const DOCUMENT_PATH = `${TEST_PATH}/graphql` as const; 14 | const OUTPUT_PATH = `${TEST_PATH}/generated` as const; 15 | const OUTPUT_FILE_NAME = "graphql.ts" as const; 16 | const OUTPUT_FILE = `${OUTPUT_PATH}/${OUTPUT_FILE_NAME}` as const; 17 | 18 | const viteConfig = { 19 | root: import.meta.dirname, 20 | plugins: [ 21 | codegen({ 22 | runOnStart: false, 23 | matchOnDocuments: false, 24 | matchOnSchemas: true, 25 | configFilePathOverride: `${TEST_PATH}/codegen.yml`, 26 | }), 27 | ], 28 | } satisfies UserConfig; 29 | 30 | describe("match-on-glob-schema", () => { 31 | let viteServer: ViteDevServer | null = null; 32 | 33 | const isFileGenerated = async (): Promise => { 34 | try { 35 | await new Promise((resolve) => setTimeout(resolve, 200)); 36 | await fs.access(OUTPUT_FILE); 37 | return true; 38 | } catch { 39 | // ignore 40 | } 41 | 42 | return new Promise((resolve, reject) => { 43 | if (!viteServer) reject("Vite server not started"); 44 | 45 | viteServer?.watcher.on("add", (path: string) => { 46 | if (path.includes(OUTPUT_FILE_NAME)) resolve(true); 47 | }); 48 | 49 | setTimeout(() => reject("Generated file not found"), 5000); 50 | }); 51 | }; 52 | 53 | beforeAll(async () => { 54 | // Files in dir1 55 | await fs.mkdir(DIR_PATH_1, { recursive: true }); 56 | await fs.writeFile(SCHEMA_PATH_1, "type Query { foo: String }"); 57 | await fs.writeFile(SCHEMA_PATH_2, "type Query { bar: String }"); 58 | 59 | // Files in dir2 60 | await fs.mkdir(DIR_PATH_2, { recursive: true }); 61 | await fs.writeFile(SCHEMA_PATH_3, "type Query { baz: String }"); 62 | await fs.writeFile(SCHEMA_PATH_4, "type Query { qux: String }"); 63 | 64 | await fs.mkdir(DOCUMENT_PATH, { recursive: true }); 65 | await fs.writeFile(`${DOCUMENT_PATH}/Foo.graphql`, "query Foo { foo }"); 66 | viteServer = await createServer(viteConfig).then((s) => s.listen()); 67 | }); 68 | 69 | afterAll(async () => { 70 | await viteServer?.close(); 71 | viteServer = null; 72 | await fs.rm(DIR_PATH_1, { recursive: true }); 73 | await fs.rm(DIR_PATH_2, { recursive: true }); 74 | 75 | await fs.rm(DOCUMENT_PATH, { recursive: true }); 76 | }); 77 | 78 | afterEach(async () => { 79 | await fs.rm(OUTPUT_PATH, { recursive: true }); 80 | }); 81 | 82 | it("generates on schema change", async () => { 83 | // Files in dir1 84 | await fs.writeFile(SCHEMA_PATH_1, "type Query { foo: Int }"); 85 | await fs.writeFile(SCHEMA_PATH_2, "type Query { bar: Int }"); 86 | 87 | // Files in dir2 88 | await fs.writeFile(SCHEMA_PATH_3, "type Query { baz: Int }"); 89 | await fs.writeFile(SCHEMA_PATH_4, "type Query { qux: Int }"); 90 | 91 | await isFileGenerated(); 92 | 93 | const file = await fs.readFile(OUTPUT_FILE, "utf-8"); 94 | 95 | expect(file).toMatchSnapshot(); 96 | }); 97 | }); 98 | -------------------------------------------------------------------------------- /test/main/__snapshots__/main.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html 2 | 3 | exports[`main > generates on file add 1`] = ` 4 | "export type Maybe = T | null; 5 | export type InputMaybe = Maybe; 6 | export type Exact = { [K in keyof T]: T[K] }; 7 | export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; 8 | export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; 9 | export type MakeEmpty = { [_ in K]?: never }; 10 | export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; 11 | /** All built-in and custom scalars, mapped to their actual values */ 12 | export type Scalars = { 13 | ID: { input: string; output: string; } 14 | String: { input: string; output: string; } 15 | Boolean: { input: boolean; output: boolean; } 16 | Int: { input: number; output: number; } 17 | Float: { input: number; output: number; } 18 | }; 19 | 20 | export type Query = { 21 | __typename?: 'Query'; 22 | bar?: Maybe; 23 | foo?: Maybe; 24 | }; 25 | 26 | export type BarQueryVariables = Exact<{ [key: string]: never; }>; 27 | 28 | 29 | export type BarQuery = { __typename?: 'Query', bar?: number | null }; 30 | 31 | export type FooQueryVariables = Exact<{ [key: string]: never; }>; 32 | 33 | 34 | export type FooQuery = { __typename?: 'Query', foo?: string | null }; 35 | " 36 | `; 37 | 38 | exports[`main > generates on file change 1`] = ` 39 | "export type Maybe = T | null; 40 | export type InputMaybe = Maybe; 41 | export type Exact = { [K in keyof T]: T[K] }; 42 | export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; 43 | export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; 44 | export type MakeEmpty = { [_ in K]?: never }; 45 | export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; 46 | /** All built-in and custom scalars, mapped to their actual values */ 47 | export type Scalars = { 48 | ID: { input: string; output: string; } 49 | String: { input: string; output: string; } 50 | Boolean: { input: boolean; output: boolean; } 51 | Int: { input: number; output: number; } 52 | Float: { input: number; output: number; } 53 | }; 54 | 55 | export type Query = { 56 | __typename?: 'Query'; 57 | bar?: Maybe; 58 | foo?: Maybe; 59 | }; 60 | 61 | export type BarQueryVariables = Exact<{ [key: string]: never; }>; 62 | 63 | 64 | export type BarQuery = { __typename?: 'Query', bar?: number | null }; 65 | 66 | export type FooQueryVariables = Exact<{ [key: string]: never; }>; 67 | 68 | 69 | export type FooQuery = { __typename?: 'Query', foo?: string | null, bar?: number | null }; 70 | " 71 | `; 72 | 73 | exports[`main > generates on server start 1`] = ` 74 | "export type Maybe = T | null; 75 | export type InputMaybe = Maybe; 76 | export type Exact = { [K in keyof T]: T[K] }; 77 | export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; 78 | export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; 79 | export type MakeEmpty = { [_ in K]?: never }; 80 | export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; 81 | /** All built-in and custom scalars, mapped to their actual values */ 82 | export type Scalars = { 83 | ID: { input: string; output: string; } 84 | String: { input: string; output: string; } 85 | Boolean: { input: boolean; output: boolean; } 86 | Int: { input: number; output: number; } 87 | Float: { input: number; output: number; } 88 | }; 89 | 90 | export type Query = { 91 | __typename?: 'Query'; 92 | bar?: Maybe; 93 | foo?: Maybe; 94 | }; 95 | 96 | export type FooQueryVariables = Exact<{ [key: string]: never; }>; 97 | 98 | 99 | export type FooQuery = { __typename?: 'Query', foo?: string | null }; 100 | " 101 | `; 102 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import process from "node:process"; 2 | import { 3 | CodegenContext, 4 | generate, 5 | loadContext, 6 | type CodegenConfig, 7 | } from "@graphql-codegen/cli"; 8 | import { debugLog } from "./utils/debugLog"; 9 | import { isCodegenConfig, isGeneratedFile } from "./utils/fileMatchers"; 10 | import { createMatchCache } from "./utils/matchCache"; 11 | import { isBuildMode, isServeMode, type ViteMode } from "./utils/viteModes"; 12 | import type { Plugin } from "vite"; 13 | 14 | export interface Options { 15 | /** 16 | * Run codegen on server start. 17 | * 18 | * @default true 19 | */ 20 | runOnStart?: boolean; 21 | /** 22 | * Run codegen on build. Will prevent build if codegen fails. 23 | * 24 | * @default true 25 | */ 26 | runOnBuild?: boolean; 27 | /** 28 | * Enable codegen integration with vite file watcher. 29 | * 30 | * @default true 31 | */ 32 | enableWatcher?: boolean; 33 | /** 34 | * Automatically add schemas and documents referenced in the codegen config 35 | * to the Vite file watcher. 36 | * 37 | * @default true 38 | */ 39 | watchCodegenConfigFiles?: boolean; 40 | /** 41 | * Throw an error if codegen fails on server start. 42 | * 43 | * @default false 44 | */ 45 | throwOnStart?: boolean; 46 | /** 47 | * Throw an error if codegen fails on build. 48 | * 49 | * @default true 50 | */ 51 | throwOnBuild?: boolean; 52 | /** 53 | * Run codegen when a document matches. 54 | * 55 | * @default true 56 | */ 57 | matchOnDocuments?: boolean; 58 | /** 59 | * Run codegen when a schema matches. 60 | * 61 | * @default false 62 | */ 63 | matchOnSchemas?: boolean; 64 | /** 65 | * Name of a project in a multi-project config file. 66 | */ 67 | project?: string; 68 | /** 69 | * Manually define the codegen config. 70 | */ 71 | config?: CodegenConfig; 72 | /** 73 | * Override parts of the codegen config just for this plugin. 74 | */ 75 | configOverride?: Partial; 76 | /** 77 | * Override parts of the codegen config just for this plugin on server start. 78 | */ 79 | configOverrideOnStart?: Partial; 80 | /** 81 | * Override parts of the codegen config just for this plugin on build. 82 | */ 83 | configOverrideOnBuild?: Partial; 84 | /** 85 | * Override parts of the codegen config just for this plugin in the watcher. 86 | */ 87 | configOverrideWatcher?: Partial; 88 | /** 89 | * Override the codegen config file path. 90 | */ 91 | configFilePathOverride?: string; 92 | /** 93 | * Log various steps to aid in tracking down bugs. 94 | * 95 | * @default false 96 | */ 97 | debug?: boolean; 98 | } 99 | 100 | export function GraphQLCodegen(options?: Options): Plugin { 101 | let codegenContext: CodegenContext; 102 | let viteMode: ViteMode; 103 | 104 | const { 105 | runOnStart = true, 106 | runOnBuild = true, 107 | enableWatcher = true, 108 | watchCodegenConfigFiles = true, 109 | throwOnStart = false, 110 | throwOnBuild = true, 111 | matchOnDocuments = true, 112 | matchOnSchemas = false, 113 | project = null, 114 | config = null, 115 | configOverride = {}, 116 | configOverrideOnStart = {}, 117 | configOverrideOnBuild = {}, 118 | configOverrideWatcher = {}, 119 | configFilePathOverride, 120 | debug = false, 121 | } = options ?? {}; 122 | 123 | const log = (...args: unknown[]) => { 124 | if (!debug) return; 125 | debugLog(...args); 126 | }; 127 | 128 | const generateWithOverride = async ( 129 | overrideConfig: Partial, 130 | ) => { 131 | const currentConfig = codegenContext.getConfig(); 132 | 133 | return await generate({ 134 | ...currentConfig, 135 | ...configOverride, 136 | ...overrideConfig, 137 | // Vite handles file watching 138 | watch: false, 139 | }); 140 | }; 141 | 142 | if (options) log("Plugin initialized with options:", options); 143 | 144 | return { 145 | name: "graphql-codegen", 146 | async config(_userConfig, env) { 147 | try { 148 | if (config) { 149 | log("Manual config passed, creating codegen context"); 150 | codegenContext = new CodegenContext({ config }); 151 | } else { 152 | const cwd = process.cwd(); 153 | log("Loading codegen context:", configFilePathOverride ?? cwd); 154 | codegenContext = await loadContext(configFilePathOverride); 155 | } 156 | if (project != null) codegenContext.useProject(project); 157 | log("Loading codegen context successful"); 158 | } catch (error) { 159 | log("Loading codegen context failed"); 160 | throw error; 161 | } 162 | 163 | viteMode = env.command; 164 | }, 165 | async buildStart() { 166 | if (isServeMode(viteMode)) { 167 | if (!runOnStart) return; 168 | 169 | try { 170 | await generateWithOverride(configOverrideOnStart); 171 | log("Generation successful on start"); 172 | } catch (error) { 173 | // GraphQL Codegen handles logging useful errors 174 | log("Generation failed on start"); 175 | if (throwOnStart) throw error; 176 | } 177 | } 178 | 179 | if (isBuildMode(viteMode)) { 180 | if (!runOnBuild) return; 181 | 182 | try { 183 | await generateWithOverride(configOverrideOnBuild); 184 | log("Generation successful on build"); 185 | } catch (error) { 186 | // GraphQL Codegen handles logging useful errors 187 | log("Generation failed on build"); 188 | if (throwOnBuild) throw error; 189 | } 190 | } 191 | }, 192 | configureServer(server) { 193 | if (!enableWatcher) return; 194 | 195 | const matchCache = createMatchCache(codegenContext, { 196 | matchOnDocuments, 197 | matchOnSchemas, 198 | }); 199 | 200 | async function checkFile(filePath: string) { 201 | log(`Checking file: ${filePath}`); 202 | 203 | if (matchCache.has(filePath)) { 204 | log("File is in match cache"); 205 | 206 | try { 207 | await generateWithOverride(configOverrideWatcher); 208 | log("Generation successful in file watcher"); 209 | } catch { 210 | // GraphQL Codegen handles logging useful errors 211 | log("Generation failed in file watcher"); 212 | } 213 | 214 | return; 215 | } 216 | 217 | if (isCodegenConfig(filePath, codegenContext)) { 218 | log("Codegen config file matched, restarting vite"); 219 | server.restart(); 220 | return; 221 | } 222 | 223 | log("File did not match"); 224 | } 225 | 226 | async function initializeWatcher() { 227 | try { 228 | log("Match cache initialing"); 229 | await matchCache.init(); 230 | 231 | if (watchCodegenConfigFiles) { 232 | log("Adding codegen config files to watcher", matchCache.entries()); 233 | server.watcher.add(matchCache.entries()); 234 | } 235 | log("Match cache initialized"); 236 | } catch (error) { 237 | log("Match cache initialization failed", error); 238 | } 239 | 240 | server.watcher.on("add", async (filePath) => { 241 | log(`File added: ${filePath}`); 242 | 243 | if (isGeneratedFile(filePath, codegenContext)) { 244 | log("File is a generated output file, skipping"); 245 | return; 246 | } 247 | 248 | try { 249 | log("Match cache refreshing"); 250 | await matchCache.refresh(); 251 | log("Match cache refreshed"); 252 | } catch (error) { 253 | log("Match cache refresh failed", error); 254 | } 255 | 256 | await checkFile(filePath); 257 | }); 258 | 259 | server.watcher.on("change", async (filePath) => { 260 | log(`File changed: ${filePath}`); 261 | 262 | await checkFile(filePath); 263 | }); 264 | } 265 | 266 | initializeWatcher(); 267 | }, 268 | } as const satisfies Plugin; 269 | } 270 | 271 | export default GraphQLCodegen; 272 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [3.7.0](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v3.6.3...v3.7.0) (2025-09-17) 2 | 3 | ### Features 4 | 5 | * support graphql codegen cli v6 ([54af525](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/54af5252cf655e87891e7088c7117f7a191ae061)), closes [#40](https://github.com/danielwaltz/vite-plugin-graphql-codegen/issues/40) 6 | 7 | ### Miscellaneous Chores 8 | 9 | * update dev deps ([5ec42e5](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/5ec42e572e84e19ec9062edef521f021e982faa3)) 10 | * update dev deps ([f37e052](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/f37e052a6ca7a6c6f7c485382685ad713ff9cc55)) 11 | * update dev deps ([228f0c5](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/228f0c5a7dc5edaad99260e7448544f5971df8ac)) 12 | 13 | ### Continuous Integration 14 | 15 | * prepare for trusted publishing ([597470c](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/597470c323ce64a6f9069cf5effb59e12db984c4)) 16 | 17 | ## [3.6.3](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v3.6.2...v3.6.3) (2025-07-09) 18 | 19 | ### Bug Fixes 20 | 21 | * downgrade unbuild to fix cjs type output ([326d2d5](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/326d2d57b455b4e7b13e7e93f06a2ec5cac8203a)), closes [#39](https://github.com/danielwaltz/vite-plugin-graphql-codegen/issues/39) 22 | 23 | ### Miscellaneous Chores 24 | 25 | * update deps ([32deb80](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/32deb80075a7e12c15ccf5c4d4074fa38b145ac0)) 26 | * update node to `v22.17.0` ([91be2a7](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/91be2a73c4c90178410a7bc75f4f55729e96dfa7)) 27 | 28 | ## [3.6.2](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v3.6.1...v3.6.2) (2025-06-24) 29 | 30 | ### Bug Fixes 31 | 32 | * add vite `v7.0.0` to peer dep range ([c9db7f9](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/c9db7f9d0b49db6b67c87b9698747aa36714c67a)) 33 | 34 | ### Miscellaneous Chores 35 | 36 | * refresh editorconfig ([fd1fd48](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/fd1fd48f5e7396b93056c006615e84b923c44957)) 37 | * update deps and refresh lockfile ([d200170](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/d2001709b35a192f57bad49e8a25617cda4634d8)) 38 | 39 | ## [3.6.1](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v3.6.0...v3.6.1) (2025-05-07) 40 | 41 | ### Bug Fixes 42 | 43 | * downgrade unbuild to fix cjs types output ([c1b0bca](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/c1b0bcadb49ea16ea7c413c3f2ab349042f8f7f4)), closes [#38](https://github.com/danielwaltz/vite-plugin-graphql-codegen/issues/38) 44 | 45 | ### Miscellaneous Chores 46 | 47 | * update deps ([3b3262a](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/3b3262a84fa3dd0099f8a89163c456ed5970bd58)) 48 | 49 | ## [3.6.0](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v3.5.0...v3.6.0) (2025-05-03) 50 | 51 | ### Features 52 | 53 | * add option to automatically add schema and document files referenced in the codegen config to the vite file watcher ([e74caad](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/e74caadd9baa5f3917ce39c36e492203baf6a6de)), closes [#37](https://github.com/danielwaltz/vite-plugin-graphql-codegen/issues/37) 54 | 55 | ### Miscellaneous Chores 56 | 57 | * improve test script ([d97f229](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/d97f229af8c9f025dd8b298a863f3b88a7650ded)) 58 | * make graphql codegen plugin helpers dep a dev dep ([21794b0](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/21794b0af20ba086b5912d866b4a61455926c6a4)) 59 | * update deps ([885191d](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/885191dc5ec1462ac60c3c1d28cceb923922d890)) 60 | * update deps ([de5935d](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/de5935d5630695136ced784a55bf6706bb89783e)) 61 | 62 | ## [3.5.0](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v3.4.5...v3.5.0) (2025-02-07) 63 | 64 | ### Features 65 | 66 | * multi-project support ([#36](https://github.com/danielwaltz/vite-plugin-graphql-codegen/issues/36)) ([3f0899d](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/3f0899d0ee546376030685c5ad0e7d43d6d0a4f5)) 67 | 68 | ## [3.4.5](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v3.4.4...v3.4.5) (2025-01-25) 69 | 70 | ### Bug Fixes 71 | 72 | * update path to codegen types ([cf6c0a9](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/cf6c0a9bd88efa085bd4751614ba738c103682d3)) 73 | 74 | ### Documentation 75 | 76 | * add badge to readme ([0fa8dc1](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/0fa8dc1244e997e4fc9b79b7748dd0c8c570fe4e)) 77 | 78 | ### Miscellaneous Chores 79 | 80 | * update dev deps ([61977c9](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/61977c90f01d10dc2b3a180c082762a7121a008a)) 81 | * update eslint config ([c60e73b](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/c60e73b9a37464d58821fd72a8ffb3a8f326d620)) 82 | * use typescript for eslint config ([b88d5c7](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/b88d5c761be260f04d736011bc4f850e8c6e5e3d)) 83 | 84 | ## [3.4.4](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v3.4.3...v3.4.4) (2024-12-14) 85 | 86 | ### Bug Fixes 87 | 88 | * update jsdoc for default value ([5b85be2](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/5b85be228e5c683cca63142743390bab8108a989)) 89 | 90 | ### Miscellaneous Chores 91 | 92 | * update dev deps ([6a175a9](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/6a175a9051ee1051153ce7405d16fe92bc3ea146)) 93 | 94 | ## [3.4.3](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v3.4.2...v3.4.3) (2024-12-07) 95 | 96 | ### Bug Fixes 97 | 98 | * remove vite and codegen cli from deps to rely on peer deps ([40e8c56](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/40e8c560486638330967f809b64616318ae877d4)) 99 | 100 | ### Miscellaneous Chores 101 | 102 | * add full git url to package file ([33c53b3](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/33c53b30cf5fe0fd7a0e82eab7047be2ab8cb4e8)) 103 | * add vite and codegen cli as dev deps ([8104f38](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/8104f38ee8e392c33761ef8692df7e64b6a849c5)) 104 | * migrate to flat eslint config ([7676e68](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/7676e682ed4e1fbe252c5324c5f11340892b4bf0)) 105 | * update deps and format ([66dd33f](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/66dd33f1a67638a1fb10be4d49e13948e2575c8a)) 106 | 107 | ### [3.4.2](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v3.4.1...v3.4.2) (2024-12-01) 108 | 109 | 110 | ### Bug Fixes 111 | 112 | * **deps:** update dep versions to be more loose ([c807514](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/c8075147f366825a85d677d477ba3d2ea3a1cdb7)) 113 | 114 | ### [3.4.1](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v3.4.0...v3.4.1) (2024-12-01) 115 | 116 | 117 | ### Performance Improvements 118 | 119 | * load and cache matches on server start ([69c1d97](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/69c1d97cc7a6df321276b6445145482a28efd8dd)), closes [#32](https://github.com/danielwaltz/vite-plugin-graphql-codegen/issues/32) [#27](https://github.com/danielwaltz/vite-plugin-graphql-codegen/issues/27) 120 | * skip match cache refresh if file is generated ([c0737a7](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/c0737a7aab210b227f5395c2b0b04873262cf3bf)) 121 | 122 | 123 | ### Tests 124 | 125 | * scope vite instances to spec directories ([90d771f](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/90d771f9ca032850eb21060a18f403dd6d3b63f4)) 126 | 127 | 128 | ### Miscellaneous Chores 129 | 130 | * **deps:** update deps ([43ed87b](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/43ed87b78c08edda73962b423fa73794c999be54)) 131 | * **deps:** use vite 6 ([64c89c9](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/64c89c9244c55c1c302e45c1370d902dc79bfb4a)) 132 | * update dev deps ([2de28d2](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/2de28d2742ce1cc08aeff0b560b0d2d57c82083d)) 133 | 134 | ## [3.4.0](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v3.3.8...v3.4.0) (2024-11-23) 135 | 136 | 137 | ### Features 138 | 139 | * support glob paths in schema ([#33](https://github.com/danielwaltz/vite-plugin-graphql-codegen/issues/33)) ([2efef2e](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/2efef2e059537af77d753151b033faf6c4a80248)), closes [#34](https://github.com/danielwaltz/vite-plugin-graphql-codegen/issues/34) 140 | 141 | 142 | ### Continuous Integration 143 | 144 | * update github action versions ([0c656ab](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/0c656ab6628f956f1a90e3fa706cf290e5f7fa4f)) 145 | 146 | 147 | ### Miscellaneous Chores 148 | 149 | * update node to `v22.11.0` lts ([d941f32](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/d941f32866db4d0beec22d6ebe1eccecc15f300a)) 150 | * use `.node-version` file ([863a61a](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/863a61a4eacedd9229102810235a521284cbb642)) 151 | 152 | ### [3.3.8](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v3.3.7...v3.3.8) (2024-06-12) 153 | 154 | 155 | ### Bug Fixes 156 | 157 | * watch documents and schemas from nested config ([5f8f08d](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/5f8f08d4b64fe53db9ce485695bb108f27db8cc6)) 158 | 159 | 160 | ### Miscellaneous Chores 161 | 162 | * normalize schema file path ([39f1361](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/39f136140018175357eec47ef7846b12103d95af)) 163 | 164 | ### [3.3.7](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v3.3.6...v3.3.7) (2024-06-01) 165 | 166 | 167 | ### Bug Fixes 168 | 169 | * prepare for vite v6 release ([b49c508](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/b49c5080006c7df2cef9a3505dc74793aaadcadd)) 170 | 171 | 172 | ### Miscellaneous Chores 173 | 174 | * **deps:** refresh lockfile and dedupe deps ([005f81e](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/005f81e77c7cfdcc9e86faec86b06d795280f5e8)) 175 | * **deps:** update deps ([6c75534](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/6c755349932a9de4c4cb1f905abc637b77686153)) 176 | * update node to `20.12.1` ([4271cfb](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/4271cfb9f84845035f4bedb1da9d31b5487d0302)) 177 | 178 | ### [3.3.6](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v3.3.5...v3.3.6) (2024-01-02) 179 | 180 | 181 | ### Miscellaneous Chores 182 | 183 | * **deps:** update deps ([063408b](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/063408bfd0ef94d5d9db0d35e5555ab1f9bc4a53)), closes [#28](https://github.com/danielwaltz/vite-plugin-graphql-codegen/issues/28) 184 | * explicitly add semantic release plugins as deps ([6da889b](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/6da889b468d1f4867e4fb2d1a68347a4f4c9fd31)) 185 | * update node to `v20.10.0` and use dedicated release config ([9ccbd00](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/9ccbd0041dd96dc6d61b44bd7002723169a3b267)) 186 | 187 | ### [3.3.5](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v3.3.4...v3.3.5) (2023-11-27) 188 | 189 | 190 | ### Bug Fixes 191 | 192 | * migrate to unbuild and fix default export issues in commonjs ([24914a2](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/24914a2801faa9de81dd66e8e86aa8f54b8a877b)) 193 | 194 | ### [3.3.4](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v3.3.3...v3.3.4) (2023-11-27) 195 | 196 | 197 | ### Bug Fixes 198 | 199 | * support esm ([951c1bb](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/951c1bbca24da07df898c566cb810bab6b1ae222)) 200 | 201 | ### [3.3.3](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v3.3.2...v3.3.3) (2023-11-17) 202 | 203 | 204 | ### Bug Fixes 205 | 206 | * broaden allowed vite dependency versions ([3b2bf38](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/3b2bf38f8fb29541eafca39fa87ed462497a2986)) 207 | 208 | ### [3.3.2](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v3.3.1...v3.3.2) (2023-11-16) 209 | 210 | 211 | ### Bug Fixes 212 | 213 | * add vite 5 as supported peer and update deps ([f2000e5](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/f2000e5ada65fadaf4bc0c96509d4aff7234efb3)) 214 | 215 | ### [3.3.1](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v3.3.0...v3.3.1) (2023-09-15) 216 | 217 | 218 | ### Bug Fixes 219 | 220 | * match on relative document paths ([ff11873](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/ff118734567f0ae2cf55132bd030cad682a6a959)), closes [#23](https://github.com/danielwaltz/vite-plugin-graphql-codegen/issues/23) 221 | 222 | ## [3.3.0](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v3.2.5...v3.3.0) (2023-08-19) 223 | 224 | 225 | ### Features 226 | 227 | * run schema and document checks at the same time ([aa8c92c](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/aa8c92cd3a8236a06a2870472ab3fe3167b2a2f9)), closes [#21](https://github.com/danielwaltz/vite-plugin-graphql-codegen/issues/21) 228 | 229 | ### [3.2.5](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v3.2.4...v3.2.5) (2023-08-18) 230 | 231 | 232 | ### Bug Fixes 233 | 234 | * add `@graphql-codegen/plugin-helpers` to dependencies ([e58be01](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/e58be018b1c6dff8a4cfd73770d20d630ed0873b)), closes [#22](https://github.com/danielwaltz/vite-plugin-graphql-codegen/issues/22) 235 | 236 | ### [3.2.4](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v3.2.3...v3.2.4) (2023-08-14) 237 | 238 | 239 | ### Bug Fixes 240 | 241 | * fix matching on schema changes ([43ee458](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/43ee4582aa2c551c36c092baf777da9c70629e99)), closes [#21](https://github.com/danielwaltz/vite-plugin-graphql-codegen/issues/21) 242 | 243 | ### [3.2.3](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v3.2.2...v3.2.3) (2023-07-25) 244 | 245 | 246 | ### Bug Fixes 247 | 248 | * add v5.0.0 to codegen cli peer deps definition ([c67977e](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/c67977e814ad1e140347f2bc729c219778a129f1)) 249 | 250 | ## [3.2.2](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v3.2.1...v3.2.2) (2023-05-25) 251 | 252 | 253 | ### Bug Fixes 254 | 255 | * add @graphql-codegen/cli@^4.0.0 as peer dependency ([fba8d5a](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/fba8d5a144cba26efc10b7ddf674863c722feb76)) 256 | 257 | ## [3.2.1](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v3.2.0...v3.2.1) (2023-04-26) 258 | 259 | 260 | ### Bug Fixes 261 | 262 | * fix watching schema while also watching documents ([8cd00ea](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/8cd00ea43479fb02a4640ecc07afdeb35a88f307)) 263 | 264 | # [3.2.0](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v3.1.0...v3.2.0) (2023-04-05) 265 | 266 | 267 | ### Features 268 | 269 | * add options for error throwing on server start or build ([4654dde](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/4654dde1606520c94b86a404fc2fb291c850b9a7)), closes [#15](https://github.com/danielwaltz/vite-plugin-graphql-codegen/issues/15) 270 | 271 | # [3.1.0](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v3.0.1...v3.1.0) (2023-02-04) 272 | 273 | 274 | ### Bug Fixes 275 | 276 | * add missing babel peer dep ([f01765d](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/f01765df9c6c3851db18b25c71a6d788f9dfe24c)) 277 | 278 | 279 | ### Features 280 | 281 | * support graphql codegen v3.0.0 ([9b8cea4](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/9b8cea4786f229eb7c0255293735894564aa714b)) 282 | 283 | ## [3.0.1](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v3.0.0...v3.0.1) (2022-12-12) 284 | 285 | 286 | ### Bug Fixes 287 | 288 | * fix plugin type issue ([7cb46b7](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/7cb46b709cfa15fc3ca8e241b83228d67ee9c78c)) 289 | 290 | # [3.0.0](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v2.3.1...v3.0.0) (2022-12-09) 291 | 292 | 293 | * feat!: support vite 4 ([6ad94c6](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/6ad94c65833b65c323739b70584895bcea5c67a7)) 294 | 295 | 296 | ### BREAKING CHANGES 297 | 298 | * requires using vite 4 due to plugin type incompatibility 299 | 300 | ## [2.3.1](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v2.3.0...v2.3.1) (2022-10-14) 301 | 302 | 303 | ### Bug Fixes 304 | 305 | * skip codegen config file check if filepath is not defined ([4b89289](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/4b8928963e9725951b55a3f6c617b2318a21b108)), closes [#13](https://github.com/danielwaltz/vite-plugin-graphql-codegen/issues/13) 306 | 307 | # [2.3.0](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v2.2.1...v2.3.0) (2022-08-26) 308 | 309 | 310 | ### Features 311 | 312 | * add option for enabling matching on schemas ([e4b57f1](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/e4b57f15d8d9140f0a05705f3f1cfe3fd1c927bd)) 313 | 314 | ## [2.2.1](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v2.2.0...v2.2.1) (2022-08-25) 315 | 316 | 317 | ### Bug Fixes 318 | 319 | * removes module export ([1872545](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/18725450c9cdcc990e0af3de5e9e1046087d3a08)) 320 | 321 | # [2.2.0](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v2.1.1...v2.2.0) (2022-08-25) 322 | 323 | 324 | ### Features 325 | 326 | * make commonjs the default with esm definitions ([df9e437](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/df9e4374bf318ff4b9beddd76e0271820de3078d)) 327 | 328 | ## [2.1.1](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v2.1.0...v2.1.1) (2022-08-25) 329 | 330 | 331 | ### Bug Fixes 332 | 333 | * fix package exports path ([d519d15](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/d519d156f999613a3b128ee68270fb9ee880994e)) 334 | 335 | # [2.1.0](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v2.0.1...v2.1.0) (2022-08-25) 336 | 337 | 338 | ### Bug Fixes 339 | 340 | * Changes package.json to module ([386a875](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/386a875c4703f0c32daf139365567ae1d071e32a)) 341 | 342 | 343 | ### Features 344 | 345 | * Adds schema to the isGraphQLDocument check ([76ae403](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/76ae403afe58e02f315aa4141af7c93d44a75032)) 346 | 347 | ## [2.0.1](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v2.0.0...v2.0.1) (2022-08-24) 348 | 349 | 350 | ### Bug Fixes 351 | 352 | * add default export for commonjs ([c93263f](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/c93263f118a249f8fc9f3f9bb0ea3d4bf02d2e0e)), closes [#4](https://github.com/danielwaltz/vite-plugin-graphql-codegen/issues/4) 353 | * remove gap in debug log output ([a75a820](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/a75a820e1daa376396466b1618085fdf047f7d87)) 354 | 355 | # [2.0.0](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v1.8.3...v2.0.0) (2022-08-11) 356 | 357 | 358 | ### Features 359 | 360 | * update debug log output to match vite 3 ([c33bba7](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/c33bba7e351ecb1fc09f015e949d539b3c804f26)) 361 | * use vite dev server restart function ([b413156](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/b4131565f28a785a460b1c19385e9cd41d1252fb)) 362 | 363 | 364 | ### BREAKING CHANGES 365 | 366 | * Requires vite version 2.7 or greater 367 | 368 | ## [1.8.3](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v1.8.2...v1.8.3) (2022-08-11) 369 | 370 | 371 | ### Bug Fixes 372 | 373 | * switch to npm and refresh packages ([be95d72](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/be95d72e51c7eb907bab31ed08671ad0ac451c9c)) 374 | 375 | ## [1.8.2](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v1.8.1...v1.8.2) (2022-08-11) 376 | 377 | 378 | ### Bug Fixes 379 | 380 | * configure semantic release to release dist ([cfc1954](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/cfc195413cfedf4e06ebcf0a84590d3e2610e27e)) 381 | 382 | ## [1.8.1](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v1.8.0...v1.8.1) (2022-08-10) 383 | 384 | 385 | ### Bug Fixes 386 | 387 | * normalize file paths before comparisons ([b855f0a](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/b855f0a886505ef801dae6c05c258ea58e4e2a90)) 388 | 389 | # [1.8.0](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v1.7.0...v1.8.0) (2022-07-13) 390 | 391 | 392 | ### Features 393 | 394 | * support vite 3 ([c881720](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/c88172034685037a2d9dc2afc1ccbaa4fa03f621)) 395 | 396 | # [1.7.0](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v1.6.0...v1.7.0) (2022-06-10) 397 | 398 | 399 | ### Features 400 | 401 | * support overriding config in certain modes ([97fce30](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/97fce30fc87fdc388ce008d47760c773ba602990)) 402 | 403 | # [1.6.0](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v1.5.2...v1.6.0) (2022-03-18) 404 | 405 | 406 | ### Features 407 | 408 | * Support passing manual codegen config ([e86079b](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/e86079bce751acfa8e5b1b0f3565a7cc3f4b2514)), closes [#3](https://github.com/danielwaltz/vite-plugin-graphql-codegen/issues/3) 409 | 410 | ## [1.5.2](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v1.5.1...v1.5.2) (2022-02-23) 411 | 412 | 413 | ### Bug Fixes 414 | 415 | * Make graphql a dev dependency ([e88edb1](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/e88edb11a4042c5637c36493633e806e9f5ee919)) 416 | 417 | ## [1.5.1](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v1.5.0...v1.5.1) (2022-02-23) 418 | 419 | 420 | ### Bug Fixes 421 | 422 | * Fix graphql dependency ([aeb9b59](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/aeb9b59da2e83822a71d0f827d0219eeedd295f8)) 423 | 424 | # [1.5.0](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v1.4.0...v1.5.0) (2022-02-10) 425 | 426 | 427 | ### Features 428 | 429 | * Add option to override codegen config file path ([ddf9c54](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/ddf9c5402c4d626d2e1761cd98d692c6cbda5efe)), closes [#1](https://github.com/danielwaltz/vite-plugin-graphql-codegen/issues/1) 430 | 431 | # [1.4.0](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v1.3.0...v1.4.0) (2022-02-09) 432 | 433 | 434 | ### Features 435 | 436 | * Add a debug option to aid in troubleshooting ([092398d](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/092398db4e4a35eefc03f564f35ceb9cc7e8ffa8)) 437 | 438 | # [1.3.0](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v1.2.0...v1.3.0) (2022-02-01) 439 | 440 | 441 | ### Features 442 | 443 | * Support disabling codegen in certain modes ([9c546a7](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/9c546a799664df7877e980b3daf8353d8498fd9a)) 444 | * Support overwriting codegen config options ([4224cec](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/4224cec993f6f7a9ca76dff4a677b9c42bb8586d)) 445 | 446 | # [1.2.0](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v1.1.1...v1.2.0) (2022-02-01) 447 | 448 | 449 | ### Features 450 | 451 | * Restart vite when codegen config file changes ([24b0d0e](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/24b0d0e6e4b1d22f40a79fd6b9e6fa5c223feba7)) 452 | 453 | ## [1.1.1](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v1.1.0...v1.1.1) (2021-08-28) 454 | 455 | 456 | ### Bug Fixes 457 | 458 | * Add fallback extension to preset config ([7e6b862](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/7e6b86298640a37522c85a3d36eca8d72cab516a)) 459 | * Make documents matcher work with multiple files ([a047a37](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/a047a3782e735eb769fc58d9e4ef7c551d338b23)) 460 | 461 | # [1.1.0](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v1.0.1...v1.1.0) (2021-08-28) 462 | 463 | 464 | ### Features 465 | 466 | * Add support for near operation file preset ([18b1227](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/18b12279629e3874edd3c691bfdede73a0a60ca4)) 467 | 468 | ## [1.0.1](https://github.com/danielwaltz/vite-plugin-graphql-codegen/compare/v1.0.0...v1.0.1) (2021-08-28) 469 | 470 | 471 | ### Bug Fixes 472 | 473 | * Add try catch on generate to keep vite running ([94e4a9b](https://github.com/danielwaltz/vite-plugin-graphql-codegen/commit/94e4a9b68460a2f3517310545b695d22ad5ad81f)) 474 | --------------------------------------------------------------------------------