-
Notifications
You must be signed in to change notification settings - Fork 971
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 Prisma Client error when running dev server w/out DB #524
Fix Prisma Client error when running dev server w/out DB #524
Conversation
@peterp I've removed Current BehaviorIf a DB is being used and the file Without the Prisma Client implementation in with import { db }
then
without import { db }
then everything runs correctly. |
The reason why it's separated is because we cannot start the dev-server if the database client isn't generated because it would throw an unhandled exception. Basically that code was added to enable this workflow:
If that's still possible then I think this can be removed, but I would love it if our golden path was the first consideration. I think how you had it originally was fine, which was to only generate the database client if |
711c520
to
2341368
Compare
Yes, it runs correctly. The tutorial commands: yarn create redwood-app path/to/app
cd path/to/app
yarn rw dev Successfully runs: $ yarn rw dev
yarn run v1.22.4
$ /Users/price/Repos/xx-delete/node_modules/.bin/rw dev
$ /Users/price/Repos/xx-delete/node_modules/.bin/dev-server
$ /Users/price/Repos/xx-delete/node_modules/.bin/prisma generate --watch
$ /Users/price/Repos/xx-delete/node_modules/.bin/webpack-dev-server --config ../node_modules/@redwoodjs/core/config/webpack.development.js
19:27:31 db |
19:27:31 db | Watching... /Users/price/Repos/xx-delete/api/prisma/schema.prisma
19:27:31 db |
19:27:31 db | ✔ Generated Prisma Client to ./../node_modules/@prisma/client in 61ms
19:27:31 db |
19:27:31 web | ℹ 「wds」: Project is running at http://localhost:8910/
19:27:31 web | ℹ 「wds」: webpack output is served from /
19:27:31 web | ℹ 「wds」: Content not from webpack is served from /Users/price/Repos/xx-delete/web
19:27:31 web | ℹ 「wds」: 404s will fallback to /index.html
19:27:32 api | Listening on http://localhost:8911
19:27:32 api | Watching /Users/price/Repos/xx-delete/api
19:27:32 api |
19:27:32 api | Now serving
19:27:32 api |
19:27:32 api | ► http://localhost:8911/graphql/ Note there is no longer a |
Nice! I guess Prisma's DB service is now working! |
I'm seeing this issue come up again with new apps:
@thedavidprice @peterp Is this the case for either of you guys too? |
Fixes #483
By default, the Prisma Client would always run when using
yarn rw dev
. In the case of runningyarn rw dev --app web
, this would cause an error. This adds a check before running Prisma Client requiring both 1) the CLI command option including 'db' and 2) API directory existing.Given that this command has 3 options, which can be used independently, I’m not sure if #490 was the best way forward -- the command
yarn rw dev web
would have started the web dev server only. The Prisma Client error would have still been an issue, however. Note: I did leave the api/ directory checks and also added it to the Prisma Client startup.Any combination of commands or an individual command will now work, e.g.
yarn rw dev api web
will run the api and web servers without error.@peterp I think it's fine as is, but it's not clear to me why 'db' exists as a separate option from 'api'. (And 'db' is a bit of a misnomer since it's running
prisma generate
.) But I guess if the two were combined, it wouldn't be possible for someone to swap the DB client in their own App, correct?@cannikin for redwoodjs/redwoodjs.com#125 you might want to use the
yarn rw dev --app web
command. (Note: --app not required.) Or if you want to delete the API directory and just runyarn rw dev
, I'd suggest you still explain what the command is doing behind the scenes -- they can optionally choose which dev servers to run. fwiw...