question about public and private procedures in trPC

so in the create-t3-app template there is this comment before the publicprocedures
This is the base piece you use to build new queries and mutations on your tRPC API. It does not
* guarantee that a user querying is authorized, but you can still access user session data if they
* are logged in.
This is the base piece you use to build new queries and mutations on your tRPC API. It does not
* guarantee that a user querying is authorized, but you can still access user session data if they
* are logged in.
this comments speaks as if the user is the one who is going to exectue the procedures but in reality I choose where this command runs and in what context exactly so what purpose do these different procedures make?
1 Reply
randoDev
randoDev2y ago
https://www.youtube.com/watch?v=x4mu-jOiA0Q https://www.c-ehrlich.dev/img/youtube/trpc-data-flows.png I'm not really sure as to what the question is, but the comment does not imply user is "executing" the query. I'm guessing you meant context being exposed to client side? Anyhow Once function is invoked from client, as far as I know on the server, new tRPC context gets created. Depending on your middleware ("use" directive on tRPC init things), you can do things to check or add things to the context that you can use later down the "server" pipeline NOTE - client does NOT have access to tRPC ctx, unless you return them as a response of your "procedure" publicProcedure does not have any middleware that checks for auth hence the comment. I don't know if it adds user data I need to check myself later default protectedProcedure (if you are using NextAuth, tRPC, Prisma) basically queries DB to check if user is authed or not and adds session object to the ctx I might be wrong but that's as far as I know for now
Christopher Ehrlich
YouTube
How tRPC really works
Larger version of the diagram: https://c-ehrlich.dev/img/youtube/trpc-data-flows.png This video explains tRPC from an app developer's perspective. Resources: tRPC: https://github.com/trpc/trpc tRPC Docs: https://trpc.io/docs/ Create T3 App: https://github.com/t3-oss/create-t3-app Chris Bautista's 🚮 NextConf Talk: https://www.youtube.com/watch?...
Want results from more Discord servers?
Add your server