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] Add codegen to watch command #8747

Merged
merged 5 commits into from
Dec 12, 2023
Merged

Conversation

esizer
Copy link
Member

@esizer esizer commented Dec 7, 2023

🤖 Resolves #8401

👋 Introduction

This allows codegen to re-run on changes to our operations. It also prevents codegen from being cached since this seemed to be causing more problems than it was solving.

🕵️ Details

We were only running codegen on the start of the watch command but it never actually watched any files. This uses concurrently to have it run in watch mode alongside the tsup watch.

Note

Something that is a tad annoying is that when you kill the process, you need to do it twice. This is a known bug and hopefully gets fixed.

🧪 Testing

Assist reviewers with steps they can take to test that the PR does what it says it does.

  1. Run watch npm run watch
  2. Go add or delete a query in apps/web
  3. Confirm the command is re-run and it affects the build

@esizer esizer changed the title [Fix] Add condegen to watch command [Fix] Add codegen to watch command Dec 7, 2023
@vd1992
Copy link
Contributor

vd1992 commented Dec 7, 2023

Cannot run on WSL

Running in a Linux environment
Running watch
-> off main, deleting a graphql operation causes no change
-> off branch, deleting a graphql operation triggers codegen action and webpack compile but no errors are emitted

@esizer
Copy link
Member Author

esizer commented Dec 8, 2023

Cannot run on WSL

Hmm, odd. I am also on WSL and it seemed to work for me 🤔

-> off branch, deleting a graphql operation triggers codegen action and webpack compile but no errors are emitted

Which query did you delete? Do you remember? I'd like to see if I can reproduce.


Update

So, @vd1992 I finally got around to trying to reproduce this based on your feedback but I am having trouble 😢 Still seems to work for me 😕

graphql-watch.mp4

@petertgiles
Copy link
Contributor

I'm not sure what to think here. 😆 Codegen doesn't seem to be watching for changes to the .graphql files. 👎 But I can manually run codegen with having to do the force flag. 👍

On the other hand, the new stuff with the client-preset is working great in watch mode, so maybe we don't care that much about the deprecated codegen stuff?

@esizer
Copy link
Member Author

esizer commented Dec 11, 2023

I'm not sure what to think here. 😆 Codegen doesn't seem to be watching for changes to the .graphql files. 👎 But I can manually run codegen with having to do the force flag. 👍

Ohh, that is a good point. Ever since we merged the client-preset (after I started this branch) the .graphql files are watched in a different place. I think I can resolve this, I had it working but merged main this morning which probably broke that 😅 .


Update: Got it working with the old config in backport codegen watch to deprecated config

Copy link
Contributor

@petertgiles petertgiles left a comment

Choose a reason for hiding this comment

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

Yay! This is working great for me now.

@esizer
Copy link
Member Author

esizer commented Dec 12, 2023

Yay! This is working great for me now.

Awesome! This is going to make the client-preset migrations far more enjoyable. You have no idea how many times I have ran npm run codegen -- --force in the past 24 hours 💀

@esizer esizer added this pull request to the merge queue Dec 12, 2023
Merged via the queue into main with commit 7cc8b99 Dec 12, 2023
9 checks passed
@esizer esizer deleted the 8401-add-codegen-to-watch-cmd branch December 12, 2023 17:22
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.

🐛 Gap between npm watch and codegen actions
3 participants