danielwaltz / vite-plugin-graphql-codegen

Zero-config vite plugin that uses the vite file watcher to run graphql codegen programmatically without needing to start a separate watcher
https://www.npmjs.com/package/vite-plugin-graphql-codegen
MIT License
83 stars 8 forks source link

The watch mode for schema files does not work when using the glob pattern #34

Closed stenin-nikita closed 2 days ago

stenin-nikita commented 2 days ago

If I specify the global pattern in the "schema" field, the plugin will not respond to changes in these files.

// codegen.ts
import type { CodegenConfig } from '@graphql-codegen/cli';

const config: CodegenConfig = {
  schema: 'src/server/**/*.graphql',
  documents: 'src/client/**/*.graphql',
  generates: {
    'src/client/__generated__/graphql.ts': {
      plugins: ['typescript', 'typescript-operations'],
    },
    'build/schema.graphql': {
      plugins: ['schema-ast'],
    },
  },
};

export default config;
// vite.config.ts
import { defineConfig } from 'vite';
import codegen from 'vite-plugin-graphql-codegen';

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

Reproduction url: https://stackblitz.com/edit/vitejs-vite-vegtzm

danielwaltz commented 2 days ago

Good news, someone has just recently opened a PR to add support for this! I am hoping to get enough to to properly test in the next couple weeks.

33

github-actions[bot] commented 2 days ago

:tada: This issue has been resolved in version 3.4.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: