Closed platon-ivanov closed 11 months ago
From readme:
You can also augment/derive new inputs from the generated inputs.ts file.
// ./src/graphql/User/inputs.ts
import { Prisma } from '@prisma/client';
// Import generated input fields definition
import { UserUpdateInputFields } from '@/graphql/__generated__/inputs';
// Note: you can't use `builder.inputType` to generate this new input
export const UserUpdateInputCustom = builder
.inputRef<Prisma.UserUpdateInput & { customArg: string }>('UserUpdateInputCustom')
.implement({
fields: (t) => ({
...UserUpdateInputFields(t),
customArg: t.field({ required: true, type: 'String' }),
}),
});
This works for your use case?
I'm looking for a way to use zod-prisma-types to add validation to the mutations generated by the code generator. I want to use this library as it's the only one I found that provides extending the fields with any Zod properties and generates all types.
I have gone through the numerous great examples provided here, but so far it seems like there is no way to extend the inputs like there is with objects, queries and mutations.
Is there a way to extend the input fields with the current API?