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

Support glob paths in schema #33

Closed Nnigmat closed 5 days ago

Nnigmat commented 1 week ago

Problem

I work on a project and we have many schema files, which we are collecting using glob, e.g. src/server/**/*.graphql.

After saving those files the watch mode codegen process does not start.

Solution

To solve this problem we can use loadSchema function which works as loadDocuments function. It takes array of paths and glob-patterns and returns array of normalized file paths.

We use this paths to match changed files.

Notes

Function loadSchema have a bug with typings. In the type definition says that it accepts only one schema pointer. But function use another module which supports array of schema pointers too.

I have created an issue to @graphql-codegen/cli - https://github.com/dotansimha/graphql-code-generator/issues/10196

danielwaltz commented 6 days ago

Thanks for your contribution! I will give it a closer look as soon as I am able to. ❤️

danielwaltz commented 5 days ago

This is awesome. Really appreciate you taking the time to write a test for it as well. Thanks!

github-actions[bot] commented 5 days ago

:tada: This PR is included in version 3.4.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: