Can I create custom terminating links?
There are cases where a user of my application is offline and can't have access to the server. I'd like to call certain functions that would properly handle that case. My best guess would be inside the
Links
. In that case can I create a terminating Link that would make that request return early without invoking the server?
On a high level, what I'm trying to do is a local-first/offline-first application with tRPC4 Replies
@BeBoRE Sorry for the ping but I'd really appreciate your opinion on this
persistQueryClient | TanStack Query Docs
This is set of utilities for interacting with "persisters" which save your queryClient for later use. Different persisters can be used to store your client and cache to many different storage layers.
Build Persisters
It works but I can't really rely on it when there's a large amounts of data to cache. I also wanna be able to make insertions in offline mode. Think a to-do list app on your phone. So I was thinking I could have an sqlite DB stored locally. So my question is, how can I run these client-side DB operations with tRPC? Links seemed like a possible option, but also this https://discord.com/channels/867764511159091230/1221200250879082647 can also be an option if it's possible... Is it?
tRPC is a tool used to achieve better end-to-end typesafety (often) between client and server. tRPC provides no utility if it's not used in a similar use-case. Your use-case requires storing and retrieving data from a data-store without crossing the boundary between client and server. If your concern is with typesafety within this context, tRPC cannot solve this issue. If you want to have typesafety when storing and retrieving data from a database you can use Drizzle or Prisma. If you need an async state manager you can use TanStack Query.
You can use createCaller to invoke a procedure when you have access to the router directly.
Server Side Calls | tRPC
You may need to call your procedure(s) directly from the same server they're hosted in, createCallerFactory() can be used to achieve this. This is useful for server-side calls and for integration testing of your tRPC procedures.