Alejo Garcia
Alejo Garcia
TtRPC
Created by Alejo Garcia on 12/7/2023 in #❓-help
best way to delete trpc?
I want to delete TRPC from a Nextjs project. What is the most appropiate way to take it out? Thanks
1 replies
TtRPC
Created by Alejo Garcia on 10/2/2023 in #❓-help
how to delete next-auth modules from trpc stacj
as the title says
2 replies
TtRPC
Created by Alejo Garcia on 10/2/2023 in #❓-help
handling errors server side
How do you guys handle server side errors 500 request on production
4 replies
TtRPC
Created by Alejo Garcia on 8/31/2023 in #❓-help
Type '{}' is not assignable in server query
Type '{ input: { slug: string; }; "": any; }' is not assignable to type 'string | StringFilter<"Category"> | undefined'.
ts getCategoryBySlug: publicProcedure
.input(z.object({ slug: z.string() }))

.query(async ({ input, ctx }) => {
const category = await ctx.prisma.category.findUnique({
where: {
slug: {input.slug},
},
});
ts getCategoryBySlug: publicProcedure
.input(z.object({ slug: z.string() }))

.query(async ({ input, ctx }) => {
const category = await ctx.prisma.category.findUnique({
where: {
slug: {input.slug},
},
});
1 replies
TtRPC
Created by Alejo Garcia on 8/29/2023 in #❓-help
createSSGHelpers
I'm trying to fetch data in getStaticProps and getting the issue "Promise<{ paths: { params: { id: number; }; }[]; fallback: "blocking"; }>' is not assignable to type 'GetStaticPaths" Wondering how to appropietly (without using deprecated functions) do SSR with trpc in nextjs.
import {
GetStaticPaths,
GetStaticPropsContext,
InferGetStaticPropsType,
} from 'next';
import { prisma } from "~/server/db";
import { appRouter } from '~/server/api/root';
import superjson from 'superjson';
import Head from 'next/head'
import { api } from "~/utils/api"
import { publicProcedure } from '~/server/api/trpc'


export async function getStaticProps(
context: GetStaticPropsContext<{ id: string }>,
) {
const ssg = await createSSGHelpers({
router: appRouter,
ctx: {},
transformer: superjson, // optional - adds superjson serialization
});
const id = context.params?.id as string;
// prefetch `post.byId`
await ssg.fetchQuery('post.byId', {
id,
});
return {
props: {
trpcState: ssg.dehydrate(),
id,
},
revalidate: 1,
};
}

export const getStaticPaths: GetStaticPaths = async () => {
const posts = await prisma.category.findMany({
select: {
id: true,
},
});
return {
paths: posts.map((post) => ({
params: {
id: post.id,
},
})),
// https://nextjs.org/docs/basic-features/data-fetching#fallback-blocking
fallback: 'blocking',
};
};
import {
GetStaticPaths,
GetStaticPropsContext,
InferGetStaticPropsType,
} from 'next';
import { prisma } from "~/server/db";
import { appRouter } from '~/server/api/root';
import superjson from 'superjson';
import Head from 'next/head'
import { api } from "~/utils/api"
import { publicProcedure } from '~/server/api/trpc'


export async function getStaticProps(
context: GetStaticPropsContext<{ id: string }>,
) {
const ssg = await createSSGHelpers({
router: appRouter,
ctx: {},
transformer: superjson, // optional - adds superjson serialization
});
const id = context.params?.id as string;
// prefetch `post.byId`
await ssg.fetchQuery('post.byId', {
id,
});
return {
props: {
trpcState: ssg.dehydrate(),
id,
},
revalidate: 1,
};
}

export const getStaticPaths: GetStaticPaths = async () => {
const posts = await prisma.category.findMany({
select: {
id: true,
},
});
return {
paths: posts.map((post) => ({
params: {
id: post.id,
},
})),
// https://nextjs.org/docs/basic-features/data-fetching#fallback-blocking
fallback: 'blocking',
};
};
1 replies