0:00 So let's head back into the 0:02 app route homepage, and inside of handle create post, well, 0:06 after we go ahead and upload the image, I now wanna supply a mutation to 0:10 actually create the post with the caption. 0:13 Now, before we do this, we need to make a change to our backend 0:16 schema for 0:17 this, because as it stands right now, if we head back into posts 0:21 and tRPC schema, the create post schema only right 0:25 now expects the caption. So let's go ahead and enhance this to now 0:29 supply the image property as well, which will be a 0:33 z.string, and we can set a min function on it 0:38 to make sure that it's supplied. 0:40 We also then wanna go back to the post service, and when we create the 0:44 post, let's go ahead and now pull this off of the create post 0:47 input, 0:49 and now we'll be saving the image file name for later retrieval. 0:54 So with this backend change in place, we can now use the file name here and the 0:58 caption we already have saved locally to create the post with our tRPC 1:02 mutation. So in order to execute our create post 1:06 mutation, 1:07 let's get access to the tRPC client object through a hook that it 1:10 exposes. 1:12 And of course, we can do this because we have the tRPC 1:15 rack context 1:16 already set up. 1:18 So we're gonna go ahead and have a posts const 1:22 and set this equal to tRPC client object that we import from 1:26 tRPC lib. And on the client object, we can now see we 1:30 have the posts router property, 1:32 and we have the create mutation as well as the find all query that we 1:36 currently have declared on this router. 1:39 So we're gonna execute the create mutation, and this will give us back
The rest of the transcript is for members.
Sign in