Skip to content

Commit

Permalink
fix upsert union args
Browse files Browse the repository at this point in the history
  • Loading branch information
omar-dulaimi committed Dec 24, 2022
1 parent ebebc70 commit 5f19742
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,15 +616,17 @@ export default class Transformer {
includeImport,
`import { ${modelName}WhereUniqueInputObjectSchema } from './objects/${modelName}WhereUniqueInput.schema'`,
`import { ${modelName}CreateInputObjectSchema } from './objects/${modelName}CreateInput.schema'`,
`import { ${modelName}UncheckedCreateInputObjectSchema } from './objects/${modelName}UncheckedCreateInput.schema'`,
`import { ${modelName}UpdateInputObjectSchema } from './objects/${modelName}UpdateInput.schema'`,
`import { ${modelName}UncheckedUpdateInputObjectSchema } from './objects/${modelName}UncheckedUpdateInput.schema'`,
];
await writeFileSafely(
path.join(Transformer.outputPath, `schemas/${upsertOne}.schema.ts`),
`${this.generateImportStatements(
imports,
)}${this.generateExportSchemaStatement(
`${modelName}Upsert`,
`z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} where: ${modelName}WhereUniqueInputObjectSchema, create: ${modelName}CreateInputObjectSchema, update: ${modelName}UpdateInputObjectSchema })`,
`z.object({ ${selectZodSchemaLine} ${includeZodSchemaLine} where: ${modelName}WhereUniqueInputObjectSchema, create: z.union([ ${modelName}CreateInputObjectSchema, ${modelName}UncheckedCreateInputObjectSchema ]), update: z.union([ ${modelName}UpdateInputObjectSchema, ${modelName}UncheckedUpdateInputObjectSchema ]) })`,
)}`,
);
}
Expand Down

0 comments on commit 5f19742

Please sign in to comment.