-
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
Tutorial 6.3: Fix prisma type error on comment creation #6045
Conversation
☁️ Nx Cloud ReportWe didn't find any information for the current pull request with the commit 2dd44c6. Check the Nx Cloud Github Integration documentation for more information. Sent with 💌 from NxCloud. |
✅ Deploy Preview for redwoodjs-docs ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
@Philzen are you using strict mode in TS? Thanks for the PR! |
Not that i would know of. 😉 |
BTW I've put this as draft for now until we a consensus which solution is preferred. I feel both approaches have something to it, i'm slightly leaning towards No. 2 currently, where we could briefly explain the approach, adding a link to the connect syntax doc – but also add an info box explaining how the unchecked variant works if people prefer to use |
@dac09 Just wanted to quickly check back if there has been any response so far from the core team on which approach is preferred? |
I prefer the "connect" version. I think it more clearly shows the intent. Found this Prisma issue that also seems to favor "connect" prisma/prisma#4322
If we teach people about the "connect" way of doing it, they will be able to handle all future relation needs they might have. If we only teach them about the "unchecked" way, they will have to discover and learn the "connect" way themselves when they run into the limitations of the unchecked way. Here's a relevant StackOverflow answer https://stackoverflow.com/a/69169106/88106 |
705a66e
to
855643d
Compare
An excellent choice, Sir @Tobbe 🧐 😉 I've updated the PR and also added a separate to commit, trying myself on an entertaining info-box that explains what we're looking at there (and what the alternatives are, also regarding TypeScript definitions). Not sure how good it is. May be worthwhile having some additional information in there. But by no means this is the wittiest, funniest infobox people will have ever read in the tutorial, so i'm open for any changes or even dropping it, it's merely a suggestion / shot from the hip. |
840671d
to
9e0ac91
Compare
…-test Otherwise a typescript error is generated when trying to provide an input that directly contains a postId
Using
postId
in the input for the createComment-test inapi/src/services/comments/comments.test.ts
gives the following red squiggle:Solutions up for debate:
Prisma.CommentUncheckedCreateInput
instead ofPrisma.CommentCreateInput
, thus being able to reuse the current JS test code on the TS tab solution without getting a type warning. This is what 53dfb68 doespostId
, but ratherconnect
the comment to the existing post using Prisma logic for both JS and TS code:I had just commited the approach for 1. when i remembered the connect syntax from Prisma. I'm unsure about the implications (which is faster, what is being done under the hood, are there additional checks), but as the only alternative to using the connect-syntax is using the "unchecked" input – that may be a hint that the "proper" / preferred Prisma-way of doing this would be the approach 2.
Looking forward to hear other people's thoughts on this.