feat: prisma typed select (#347)

* feat: wip prisma gql select

* feat: stronger api using decorator

* feat: add PrismaSelect everywhere

* fix: remove unused

* fix: remove seed debug
This commit is contained in:
Jérémy M
2023-06-22 11:17:31 +02:00
committed by GitHub
parent eb9be6894e
commit ca283a2196
35 changed files with 1081 additions and 578 deletions

View File

@ -0,0 +1,32 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const fs = require('fs');
const path = require('path');
const { getDMMF, getSchemaPath } = require('@prisma/internals');
async function generateTypes() {
const schemaPath = await getSchemaPath();
const dmmf = await getDMMF({
datamodel: fs.readFileSync(schemaPath, 'utf-8'),
});
let content =
'// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.\n';
content += "import { Prisma } from '@prisma/client';\n\n";
content += 'export type ModelSelectMap = {\n';
for (const model of dmmf.datamodel.models) {
content += ` ${model.name}: Prisma.${model.name}Select;\n`;
}
content += '};\n';
fs.writeFileSync(
path.join(__dirname, '../src/utils/prisma-select/model-select-map.ts'),
content,
);
}
generateTypes().catch((e) => {
console.error(e);
process.exit(1);
});