isaac_way
isaac_way
TtRPC
Created by Aleph on 4/3/2024 in #❓-help
1 trpc api server for 1 or many clients.
put them into the same monorepo
3 replies
TtRPC
Created by Maj on 5/24/2023 in #❓-help
useQuery hook modify data on fetch.
by default react query will refetch on window focus. you'll probably want to parse the json into an object before returning it. Zod is pretty nice for this:
const MyJsonSchema = z.object({
prop: z.string(),
prop2: z.number()
})

const JsonStringSchema = z.string().transform(v=>{
return MyJsonSchema.parse(JSON.parse(v));
})
const MyJsonSchema = z.object({
prop: z.string(),
prop2: z.number()
})

const JsonStringSchema = z.string().transform(v=>{
return MyJsonSchema.parse(JSON.parse(v));
})
And then return JsonStringSchema.parse(databaseObject.jsonStringField) from your procedure
5 replies
TtRPC
Created by isaac_way on 4/18/2023 in #❓-help
"This is likely not portable" error
probably what caused it to start happening
16 replies
TtRPC
Created by isaac_way on 4/18/2023 in #❓-help
"This is likely not portable" error
hmm I just disabled hoisting to fix some other issue lol
16 replies
TtRPC
Created by isaac_way on 4/18/2023 in #❓-help
"This is likely not portable" error
had composite: true in the tsconfig.json, removing that fixed it idk why
16 replies
TtRPC
Created by zrilman on 2/18/2023 in #❓-help
Input is too big for a single dispatch
It's pretty easy to just wrap a mutation call in a react query useQuery hook, probably the simplest workaround I think:
import {useQuery} from '@tanstack/react-query';

function usePostsQuery() {
const client = api.useContext().client;
return useQuery({queryFn: async ()=>{
return await client.posts.getPosts.mutate();
}})
}
import {useQuery} from '@tanstack/react-query';

function usePostsQuery() {
const client = api.useContext().client;
return useQuery({queryFn: async ()=>{
return await client.posts.getPosts.mutate();
}})
}
7 replies
TtRPC
Created by jonasmerlin on 2/7/2023 in #❓-help
How are people handling authorization?
If you’ve just started on your app, maybe consider using create-t3-app to generate you project. It sets up next auth for you
16 replies