Ignition 98
Ignition 98
TtRPC
Created by Ignition 98 on 1/4/2024 in #❓-help
TRPC to connect a client app with a backend apigateway ?
@Nick Lucas Thanks! Do you have an example how TRPC can call a service on a backend ? Would create a caller-function be the right choice for this purpose?
// 1. create a caller-function for your router
const createCaller = createCallerFactory(appRouter);

// 2. create a caller using your `Context`
const caller = createCaller({
foo: 'bar',
});

// 3. use the caller to add and list posts
const addedPost = await caller.post.add({
title: 'How to make server-side call in tRPC',
});

const postList = await caller.post.list();
// 1. create a caller-function for your router
const createCaller = createCallerFactory(appRouter);

// 2. create a caller using your `Context`
const caller = createCaller({
foo: 'bar',
});

// 3. use the caller to add and list posts
const addedPost = await caller.post.add({
title: 'How to make server-side call in tRPC',
});

const postList = await caller.post.list();
4 replies
TtRPC
Created by Ignition 98 on 11/12/2023 in #❓-help
Difference between createTRPCNextAppDirServer, createTRPCNext and createTRPCProxyClient?
No idea tbh..
30 replies
TtRPC
Created by Ignition 98 on 11/12/2023 in #❓-help
Difference between createTRPCNextAppDirServer, createTRPCNext and createTRPCProxyClient?
Sure
30 replies
TtRPC
Created by Ignition 98 on 11/12/2023 in #❓-help
Difference between createTRPCNextAppDirServer, createTRPCNext and createTRPCProxyClient?
What are you having problems with?
30 replies
TtRPC
Created by Ignition 98 on 11/12/2023 in #❓-help
Difference between createTRPCNextAppDirServer, createTRPCNext and createTRPCProxyClient?
Also Supabase setup?
30 replies
TtRPC
Created by Ignition 98 on 11/12/2023 in #❓-help
Difference between createTRPCNextAppDirServer, createTRPCNext and createTRPCProxyClient?
No, I haven't. That's what I'm trying to do atm with Next, TRPC and Supabase Auth.
30 replies
TtRPC
Created by Ignition 98 on 11/12/2023 in #❓-help
Difference between createTRPCNextAppDirServer, createTRPCNext and createTRPCProxyClient?
Thanks a lot for the detailed answer!
30 replies
TtRPC
Created by Ignition 98 on 11/12/2023 in #❓-help
Difference between createTRPCNextAppDirServer, createTRPCNext and createTRPCProxyClient?
I'm referring to step 3 from the docs. https://trpc.io/docs/server/data-transformers Currently I'm using the following structure to make server side calls to my database:
export const api = createTRPCProxyClient<AppRouter>({
transformer: superjson, // <--
// [...]
});
export const api = createTRPCProxyClient<AppRouter>({
transformer: superjson, // <--
// [...]
});
export default async function Home() {
const hello = await api.post.hello.query({ text: "from tRPC" });
return (
<p className="text-2xl text-white">
{hello ? hello.greeting : "Loading tRPC query..."}
</p>
)
}
export default async function Home() {
const hello = await api.post.hello.query({ text: "from tRPC" });
return (
<p className="text-2xl text-white">
{hello ? hello.greeting : "Loading tRPC query..."}
</p>
)
}
I don't quite get what benefit I'd get if I was to use createTRPCNextAppDirServer or createTRPCNext instead of createTRPCProxyClient as all of them are capable of making server side calls.
30 replies