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(cli): fix watching of schema files outside of working directory #1998

Merged
merged 3 commits into from
Aug 19, 2024

Conversation

lubosmato
Copy link
Contributor

@lubosmato lubosmato commented Aug 16, 2024

The PR fixes watching of schema files that are outside of working directory.

Solves #1997

@vicary
Copy link
Member

vicary commented Aug 19, 2024

@lubosmato Thanks for contributing!

There are some missing bits that I'd like to add before merging, would you please enable Allow edits from maintainers?

@lubosmato
Copy link
Contributor Author

Hi @vicary, thank you for this amazing project. Allow by maintainers should be allowed.

@vicary vicary merged commit 0db93e1 into gqty-dev:main Aug 19, 2024
4 checks passed
@github-actions github-actions bot mentioned this pull request Aug 19, 2024
@vicary
Copy link
Member

vicary commented Aug 19, 2024

@lubosmato For some reason a canary is not published, would you like to test the main branch locally before release?

@lubosmato
Copy link
Contributor Author

@vicary I have just tested it and it's not working 🤔. I will check what is the problem and ping back.

@lubosmato
Copy link
Contributor Author

isMatch is now checking resolved file path against parent folder which is not correct. E.g. fullPath = "./api/schema.graphql" and wachEndpoints = ["./api/"].

The correct isMatch params should be fullPath and resolved filenames of endpoints:

diff --git a/packages/cli/src/commands/default.ts b/packages/cli/src/commands/default.ts
index 1f54a4b4..9d9c4508 100644
--- a/packages/cli/src/commands/default.ts
+++ b/packages/cli/src/commands/default.ts
@@ -274,12 +274,13 @@ export const addCommand = (command: Command) => {
 
         // Watch file changes
         (async () => {
-          const watchEndpoints = endpoints
-            .map((endpoint) => path.resolve(endpoint))
+          const watchFiles = endpoints
+            .map((endpoint) => path.resolve(endpoint));
+          const watchDirectories = watchFiles
             .map((endpoint) => path.dirname(endpoint));
 
           const watchIterable = pipeAsync(
-            [...new Set(watchEndpoints)],
+            [...new Set(watchDirectories)],
             map((path) =>
               pipeAsync(
                 watch(path),
@@ -296,7 +297,7 @@ export const addCommand = (command: Command) => {
 
             const fullPath = path.resolve(parentPath, filename);
 
-            if (!isMatch(fullPath, watchEndpoints)) continue;
+            if (!isMatch(fullPath, watchFiles)) continue;
 
             // Already queued
             if (shouldRun) continue;

vicary added a commit that referenced this pull request Aug 19, 2024
…1998)

* fix(cli): fix watching of schema files that are outside of working directory

* chore(package/cli): cosmetic touch-ups

* chore(package/cli): changeset

---------

Co-authored-by: Vicary A <[email protected]>
@vicary
Copy link
Member

vicary commented Aug 19, 2024

@lubosmato My bad for the oversight, pushed again to main.

vicary added a commit that referenced this pull request Aug 20, 2024
…1998)

* chore(package/cli): cosmetic touch-ups

* chore(package/cli): changeset

---------

Co-authored-by: Vicary A <[email protected]>
vicary added a commit that referenced this pull request Aug 20, 2024
…1998)

* chore(package/cli): cosmetic touch-ups

* chore(package/cli): changeset

---------

Co-authored-by: Vicary A <[email protected]>
vicary added a commit to lubosmato/gqty that referenced this pull request Aug 21, 2024
…qty-dev#1998)

* chore(package/cli): cosmetic touch-ups

* chore(package/cli): changeset

---------

Co-authored-by: Vicary A <[email protected]>
vicary added a commit to lubosmato/gqty that referenced this pull request Aug 21, 2024
…qty-dev#1998)

* chore(package/cli): cosmetic touch-ups

* chore(package/cli): changeset

---------

Co-authored-by: Vicary A <[email protected]>
vicary added a commit that referenced this pull request Aug 24, 2024
…1998)

* fix(cli): fix watching of schema files that are outside of working directory

* chore(package/cli): cosmetic touch-ups

* chore(package/cli): changeset

---------

Co-authored-by: Vicary A <[email protected]>
vicary added a commit that referenced this pull request Aug 25, 2024
…1998)

* fix(cli): fix watching of schema files that are outside of working directory

* chore(package/cli): cosmetic touch-ups

* chore(package/cli): changeset

---------

Co-authored-by: Vicary A <[email protected]>
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