fix: Don't treat schema URLs as relative file paths for the watcher #10282
+32
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🚨 IMPORTANT: Please do not create a Pull Request without creating an issue first.
Any change needs to be discussed before proceeding. Failure to do so may result in the rejection of the pull request.
Description
Partial fix for #10281. This PR makes sure that schema URLs are not being treated as file paths when creating a watcher for
--watch
. This allows the common watched directory to be a nested directory, which in turn dramatically increases performance of the watcher as it doesn't have to watch all the extra directories (likenode_modules
).Type of change
How Has This Been Tested?
Test Environment:
@graphql-codegen/...
: masterChecklist:
Further comments
As I said, it's only a partial fix. This resolves the issue of schema URL being treated as a file, which forces the watcher to watch the project root. However, this still does not allow the watcher to be efficient and performant when the graphql-codegen config is located in the project root, or when watched files are in two different locations.
A proper fix would be a refactor of the
watcher.ts
- one that utilizes multiple watcher subscriptions per each watched path OR one that automatically specifies all directories except relevant as ignored. I'm not sure which solution would give better performance, and I'm not sure that this project will accept a PR making those changes. Please let me know if this refactor would be possible.