-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Setting query name in cell generator #6442
Conversation
Apologies if opening a few PR's, especially those related to "good-first-issue"'s, in a short period of time is bad etiquette. I'll make this the last one. |
Thanks so much for the PRs! I haven't had a chance to review yet, but just a call out that the query name has to match the imported type too! |
Just glad to hopefully be somewhat helpful and of course absolutely no rush. I think it was setup somewhat conveniently and it was simply a case of overriding the value of the |
Okay the current blocker for this PR is the Listr/prompt compatibility. That is Listr doesn't seem to support user input well at all. An example of this is this current PR which somewhat naively uses prompt within the Listr task and the prompt text is drawn over and it's a big unusable mess. I think the prompt here is quite useful and in some sense needed to confirm the user accepts an action which might come back to bite them. So, if you want to keep the prompt then you need to ditch Listr but from what I can see the entire set of generators, not just this cell generator, is wrapped up in a Listr based setup. This leaves me a touch stuck. Maybe there is a way to get prompts and Listr to play nice? Maybe I'd have to rip out this generator from the entire generators setup - yikes! @Tobbe maybe you have some helpful insight into this conundrum of mine? |
I don't have an easy/quick solution I'm afraid. You seem to have a good grip on the current state of things. We're really starting to run into the limits of what Listr can handle. As I said over in that PR I love to link 😉 #3989 I think tasktree is worth a look It would be super valuable if you could do a quick experiment with Lstr2 and tasktree and any other options you can find and see how they would work with our CLI If we find a tool (or tool combo) that we really believe in I don't see a problem with switching over. It'd have to be a process with a lot of really small steps, switching out for one command at a time |
Okay this PR's original issue is over 2 years old so it's clearly not pressing 😆. I'll produce a quick experiment with Listr2 which has docs on user input support with enquirer. Both seem very popular from my initial look. I'll experiment with tasktree too if I find the time. |
Changed to use listr2 and enquirer prompts - breaking
What initially got me interested in tasktree wasn't the progress bars. It was its (potential) better control over its output. Especially with Listr you often get a lot of duplicated output. And sometimes if you try to add console logs to the output it doesn't show up at all. Listr2 is said to be better in these regards, but apparently still hadn't fully figured it out. That's where tasktree comes in. You (probably) won't see it unless you have lots of output spanning more than one screen. Read more here listr2/listr2#296 |
I had seen this issue mentioned in another redwood PR. Does appear that In my head it comes down to three options then:
I know I'd lean towards option 3 but at the end of the day I'm just a random guy who has never worked on a big js project like this and hadn't even looked into the codebase a week ago 😆 |
Thanks @Josh-Walker-GM for the effort into this! I think I'd prefer to disambeguate the two issues - agree that LIstr has limitations, but I'd prefer to switch the libraries in a separate PR - it's a bigger piece of work, as you can see! Even if we do the switch little at a time, I think it's better for us to make sure we don't introduce sideffects like this! For the functionality you're adding to this PR, I think just erroring out with the message "Query name ${queryName}" is not unique would be just fine I think! |
…me-nolistr Revert "Changed to use listr2 and enquirer prompts - breaking"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requesting a few small changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Josh-Walker-GM 🚀🚀
Added a test on your behalf
@@ -17,12 +17,13 @@ | |||
"@redwoodjs/forms": "3.0.2", | |||
"@redwoodjs/router": "3.0.2", | |||
"@redwoodjs/web": "3.0.2", | |||
"humanize-string": "2.1.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey all, saw this change when merging the patch release branch back into main. Could we go without this change, or is this package necessary for this PR? I noticed we didn't change the CRWA template, so something may be missing if this one is necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting that it shows up here now.
Danny and I discovered a while ago that it's been missing as a web side dependency.
Let me try to find a PR that's relevant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the PR
https://github.com/redwoodjs/redwood/pull/6221/files
humanize-string should not be a dep in the test project
Ackshually... Let me check again
So. That PR I linked above removed the import of humanize-string from all the scaffolded components in the test project (and any actual RW app too). Instead it moved to the new /web/src/lib/formatters.ts file.
So it should be added as a dependency to the web side as soon as you scaffold a model.
Previously it wasn't an explicit dependency on the web package. But it was a dependency on the cli package, so we got away with it.
Resolves #343
Description
Adds a
query
argument to theyarn rw g cell
command which allows the user to specify a specific GraphQL query name be used in the generated cell.Todo
Fix: Prompt conflicts with existing cli interface when asking user to confirm non-unique query name.Discuss: Confirm this concerns only the "web" files - changing the implementation of the query name in the "api" is not this generators duty?