Replies: 1 comment
-
Hey @cktang88 thanks for opening this! I can definitely see how that seems a bit nicer. One downside, is that you have to then refactor if you want to do something like this: type UpdateProjectInput = {
where: ProjectUpdateArgs["where"]
data: Omit<ProjectUpdateArgs["data"], "id">
} I'm curious to know what others think! By the way, once zod adds support or matching existing types, I think it will be a lot better (and more secure!) to scaffold queries and mutations by default with input validation like this: import db, {FindOneUserArgs} from "db"
import {SessionContext} from "blitz"
import * as z from "zod"
export const GetUserInput: z.type<Pick<FindOneUserArgs, "where">> = z.object({
where: z.object({
id: z.string()
})
})
export type GetUserInputType = z.infer<typeof GetUserInput>
export default async function getUser(
input: GetUserInput,
ctx: {session?: SessionContext} = {},
) {
const {id} = GetUserInput.parse(input)
// stuff
} If people want, we could also add |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently in
app/projects/mutations/updateProject.ts
for example, the type is something like:Instead I think it'd be cleaner just to do:
Beta Was this translation helpful? Give feedback.
All reactions