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

feat: add option for enabling matching on schemas #10

Closed danielwaltz closed 2 years ago

danielwaltz commented 2 years ago

Adds two new options for configuring if you want vite to match and run codegen on documents and schemas.

Made the schema matcher optional (and defaulted it off) as there's a chance for this to cause recursion in some projects. If your codegen script also generates the schema file that used as the input schema it loops detecting a change, generating a schema file, which gets picked up as a change, etc.

Also updated the schema matcher to be more accurate about what it's doing, and makes it clear it only works if the defined schema is a path (as other options like URLs cannot be matched against).

@andrew-w-ross Especially curious about your thoughts on this change, and if it still enables you do achieve your goals on your project!

andrew-w-ross commented 2 years ago

@danielwaltz Yeah that works for me, I never expected it to work on urls for the schema. Just to let you know of the use case some projects will download the server schema as a separate schema.graphql file and it would be nice for plugins that just need schema to update in watch mode.

github-actions[bot] commented 2 years ago

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

The release is available on:

Your semantic-release bot :package::rocket: