Typedef
Typedef
TtRPC
Created by Typedef on 8/31/2023 in #❓-help
The inferred type of this node exceeds the maximum length the compiler will serialize.
No description
10 replies
TtRPC
Created by Typedef on 8/10/2023 in #❓-help
useContext not Invalidating
What are the possible mistakes if useContext wont invalidate when doing the following:
const utils = trpc.useContext();
const user = trpc.user.getUser.useQuery();
const updateUser = trpc.user.updateUser.useMutation({
onSuccess: () => {
utils.user.getUser.invalidate();
}
});
const utils = trpc.useContext();
const user = trpc.user.getUser.useQuery();
const updateUser = trpc.user.updateUser.useMutation({
onSuccess: () => {
utils.user.getUser.invalidate();
}
});
Used to work before but stopped working when I turned my entire repo to turborepo.
15 replies
TtRPC
Created by Typedef on 4/22/2023 in #❓-help
Invalid Val
Does TRPC string input have a limit? https://prnt.sc/KlXlyoGrzP8P Edit: It was actually from stripe metadata
4 replies
TtRPC
Created by Typedef on 3/21/2023 in #❓-help
Set custom header for fetchRequestHandler
Is this possible? currently getting cors issue. Trying to use nextjs's edge function with trpc..
import { type NextRequest } from "next/server";
import { appRouter, createContext } from "api";
import { fetchRequestHandler } from "@trpc/server/adapters/fetch";

export const config = {
runtime: "edge",
};

export default async function handler(req: NextRequest) {
if (req.method === "OPTIONS") {
return new Response(null, {
status: 200,
});
}

return fetchRequestHandler({
endpoint: "/api/trpc",
router: appRouter,
createContext,
req,
onError:
process.env.NODE_ENV === "development"
? ({ path, error }) => {
console.error(`[tRPC] failed on ${path}: ${error}`);
}
: undefined,
});
}
import { type NextRequest } from "next/server";
import { appRouter, createContext } from "api";
import { fetchRequestHandler } from "@trpc/server/adapters/fetch";

export const config = {
runtime: "edge",
};

export default async function handler(req: NextRequest) {
if (req.method === "OPTIONS") {
return new Response(null, {
status: 200,
});
}

return fetchRequestHandler({
endpoint: "/api/trpc",
router: appRouter,
createContext,
req,
onError:
process.env.NODE_ENV === "development"
? ({ path, error }) => {
console.error(`[tRPC] failed on ${path}: ${error}`);
}
: undefined,
});
}
23 replies
TtRPC
Created by Typedef on 2/22/2023 in #❓-help
[Help] Turbo shared types
I have a turborepo with two apps (web and embed). web is a t3 stack and embed is a create-react-app. I am trying to use the trpc endpoint from web to embed. I managed to make it work by configuring web's cors. However, I am getting type issues when importing AppRouter in the embed app. I don't think you can just import AppRouter from web like import type { AppRouter } from "../../../web/src/server/routers/_app"; which is currently what I am doing. So my question is how would I go about this? do I need to somehow share the types between the two? if so how would I do it?. Should I just seperate trpc as an internal package?
3 replies