-
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
codegen graphql schema #5213
codegen graphql schema #5213
Conversation
✅ Deploy Preview for redwoodjs-docs canceled.
|
Note that this conflicts pretty heavily with #5216 which right now needs to evaluate code before running |
@orta This PR mainly touches graphqlSchema.ts and yours is mainly in graphqlCodeGen.ts. Can you please help me understand how they conflict? Thanks! |
oh good point - it doesn't! |
48d9fa9
to
63736fd
Compare
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.
@Tobbe I added some language from the docs to help resolve the SDL generator type issue.
I think similar language there and a link to the docs when published can be helpful.
e019bd2
to
0cc8758
Compare
99e72cd
to
fa1bca7
Compare
@Tobbe Awesome! This is gonna save us a ton of Discord threads. 😄 I have two suggestions: First, I'm worried the So I propose we change it to:
My reasoning is that you have to generate one before the other, so don't tell them to start over, just tell them to generate the other one. You could comment out the relation fields, generate the SDLs/scaffolds, comment the relations fields back in, and force generate the SDLs/scaffolds, but that's a few too many steps for me when all I need to do is run the other SDL/scaffold generator. But thoughts? Second, I feel like the message should stand out more. Maybe we could style it a bit to make it more eye catching? This is the code I added (along with a chalk import—it's already a dependency of this package) to get that message; happy to commit it if you agree: console.error(
[
` ${chalk.bgYellow(` ${chalk.black.bold('Heads up')} `)}`,
'',
chalk.yellow(
` It looks like you have a ${name} model in your Prisma schema.`
),
chalk.yellow(
` If it's part of a relation, you may have to generate SDL or scaffolding for ${name} too.`
),
chalk.yellow(
` If you haven't done so yet, ignore the error message here and do so now.`
),
'',
chalk.yellow(
` See the ${terminalLink(
'Troubleshooting Generators',
'https://redwoodjs.com/docs/schema-relations#troubleshooting-generators'
)} section in our docs for more help.`
),
'',
].join('\n')
) |
Yes! I ❤️ this Dom! This is so much better than what I had. What terminal/shell do you have? Why don't you get the nice looking link I get? (iTerm2 + zsh) To keep iterating on the text a little bit, what do you think of
|
I use the default mac terminal and fish shell. I think the mac terminal is unsupported. It's ok! I like the copy! If I could suggest one more thing, I'd change I'll add the commit now. There's one thing I don't know how to do yet: how do you get "Book"? |
Hi! sorry to but into this conversation, this all looks great and i think it'll solve an issue i was butting my head against. I was trying to look through this pr to see what your solution looked like but i couldn't find the successful test fixture, so i was hoping someone here could take a quick peek/ this could be illuminating for anyone else coming across this pr like me before this gets released.
then when scaffolding these i run into the problem
this works but seems... not ideal. is it possible to import the types from one file into another? |
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.
LGTM. It's better to run codegen from core
when you have all the info already, instead of using the cli
. You can also control how it's being executed and break the dependency to fs
(and reduce a lot of dependencies you might not need...)
@jnhooper you shouldn't have to import types into files, just run the sdl or scaffold generator for one model after the other while expecting the first model that to have type errors. Does that make sense? So it'd be:
|
…ok-smoke-test * 'main' of github.com:redwoodjs/redwood: Remove extra checkout in RC workflow (redwoodjs#5414) chore(deps): update dependency @azure/msal-browser to v2.24.0 (redwoodjs#5412) fix(deps): update react monorepo (redwoodjs#5406) cli upgrade: Always search from the start for semvers (redwoodjs#5368) codegen graphql schema (redwoodjs#5213) fix(deps): update dependency core-js to v3.22.4 (redwoodjs#5409) fix(deps): update typescript-eslint monorepo to v5.22.0 (redwoodjs#5410) Add graphql-scalars to graphql-server (redwoodjs#5408) Update yarn.lock v1.2.1 fix(deps): update dependency cross-undici-fetch to v0.3.6 (redwoodjs#5402) fix(deps): update dependency cross-undici-fetch to v0.3.5 (redwoodjs#5398) fix(deps): update dependency cross-undici-fetch to v0.3.3 (redwoodjs#5378) chore(story📗): extract MSW logic into a loader (redwoodjs#4919)
Use
codegen
instead of programmatically calling the CLI.This sets us up to better handle #4762
If/when #4849 goes in we could add a link to that when printing the error message
Easiest way to test this PR is to use the Gitpod link and then paste the Book and Shelf models below into schema.prisma
After that just run
yarn rw g sdl Book
and you'll see an error message printed