Mutation or query for something that updates db, but runs on every app load?

I have 2 operations that need to run before showing my app UI. Those operations perform updates in DB. Should they be TRPC mutations or queries?
Generally, mutations But if it's something like getting a session then a Query could be argued for. Queries are often passive in UIs, particularly with react-query: you just declare you need the result. Mutations are more active, you have to call them explicitly
This perform sync of external data based on which i display content of the app later on Thanks for your input
this sounds like a situation where it’s not ultra clear which is better. IMO, choose the one that is easier to deal with on the front end. useQuery and useMutation have very different front end behaviors but are basically identical on the backend in trpc, one is probably going to be a lot easier to use when building out ur front end logics, so use that one. No one is going to be able to know which is easier for you in this situation except you, probably I had a situation like this recently where I asked around on twitter which made more sense for my situation. Everyone said “query” when in fact a useMutation ended being a lot easier to use for my case

Looking for more? Join the community!

Recommended Posts
Websocket is not defined errorI'm getting a "WebSocket is not defined error" on my next app connected to an express backend. Any i@trpc/server in a non-server environment Error in Azure CIIm trying to add vitest unit tests for my trpc procedures. I followed some examples and on the localHow are people handling authorization?I noticed that with V10, any mentions of `trpc-shield` are gone from the documentation. Also, it onlVitest context router callerHi, Im trying to setup vitest to test trpc. I would like to have a trpc approuter caller to be accesCannot read properties of undefined (reading 'data') of res.error.data, when trpc errors outHello everyone, I am using `@trpc/react-query` alongside `trpc` for express, and I am experiencing aExtending middlewareshttps://trpc.io/docs/middlewares#extending-middlewares Is this available?Calling a trpc endpoint inside of a trpc endpointHey all. I'm wondering how I am able to call these endpoints from within themselves? For example,Frozen input paramIs it possible to define a parameter on input schema (zod) that will have a hardcoded/frozen value wtype mismatch between tRPC return (in sveltekit) and defined typei've got this piece of code: ```ts read: async () => { const res = await trpc($page).getCards.querpre fetch serveral prodecures dynamicallyHello!. I'm developing a React Native app which needs an offline mode for some assets that the user procedure input contextIs it possible to accesss context in trpc procedure input validation? I have an aray of values in tIs it normal to separate resolvers from routers?Wondering if it's common and/or whether it's a good idea to attempt to separate procedures from the i have an infinite loop within my hook but apps works as expected.when i console log inside this hook, it repeats non-stop every few seconds, but my app is working astrpc query running twiceHey guys. I have a trpc endpoint which makes a request to the discord api to fetch a list of the use