vite-plugin-graphql-codegen icon indicating copy to clipboard operation
vite-plugin-graphql-codegen copied to clipboard

chore: rewrite file watcher

Open yurks opened this issue 1 year ago • 1 comments

Currently, file watcher asynchronously retrieves documents and schemas on each project file changes, which is slow, and caused unreasonably high resources usage.

Changes made

  • resolve all configured documents and schemas only once on server startup and simply check file path matching in watcher.
  • fix cases when schema path defined with dot like ./src/schema.graphql by resolve absolute schema paths.
  • fix cases when documents defined with glob pattern like ./src/**/*.graphql, and modifying src/path/api.graphql.generated.ts file caused false positive check and trigger watcher for that file.

Also, this PR should resolve OOM issues reported in https://github.com/danielwaltz/vite-plugin-graphql-codegen/issues/27

Side changes

  • reduce amount of log records, as currently it contains a lot of records which is not related to plugin: modifying any file in project produces ~5 log entries. Below are screenshots of the same number of interactions with project files demonstrating this.

Before

image

After

image

yurks avatar Jun 07 '24 13:06 yurks

Thanks for your effort on these PRs! Hope to carve out the time in the next week or so to test them out and get them merged. 🎉

danielwaltz avatar Jun 07 '24 18:06 danielwaltz

Thanks again for the work on this! I have implemented this strategy in a slightly different way that still supports the use cased of adding files. Please let me know if you run into any issues in the latest version!

danielwaltz avatar Dec 01 '24 12:12 danielwaltz