Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Don't treat schema URLs as relative file paths for the watcher #10282

Merged
merged 2 commits into from
Feb 9, 2025

Conversation

oprypkhantc
Copy link
Contributor

🚨 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 (like node_modules).

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Unit tests

Test Environment:

  • OS: macOS
  • @graphql-codegen/...: master
  • NodeJS: 20.15.1

Checklist:

  • I have followed the CONTRIBUTING doc and the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

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.

Copy link

changeset-bot bot commented Feb 7, 2025

🦋 Changeset detected

Latest commit: b2b626c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@graphql-codegen/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Collaborator

@eddeee888 eddeee888 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@eddeee888 eddeee888 merged commit 7d7760d into dotansimha:master Feb 9, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants