@pothos/plugin-prisma 4.0.0-next.1 → 4.0.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/package.json +5 -5
- package/src/generator.ts +15 -13
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pothos/plugin-prisma",
|
|
3
|
-
"version": "4.0.0-next.
|
|
3
|
+
"version": "4.0.0-next.2",
|
|
4
4
|
"description": "A Pothos plugin for more efficient integration with prisma",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./dts/index.d.ts",
|
|
@@ -71,12 +71,12 @@
|
|
|
71
71
|
"graphql-scalars": "^1.23.0",
|
|
72
72
|
"graphql-tag": "^2.12.6",
|
|
73
73
|
"prisma": "^5.16.1",
|
|
74
|
-
"@pothos/core": "4.0.0-next.0",
|
|
75
|
-
"@pothos/plugin-complexity": "4.0.0-next.0",
|
|
76
74
|
"@pothos/plugin-errors": "4.0.0-next.0",
|
|
77
|
-
"@pothos/
|
|
75
|
+
"@pothos/test-utils": "2.0.0-next.0",
|
|
78
76
|
"@pothos/plugin-simple-objects": "4.0.0-next.0",
|
|
79
|
-
"@pothos/
|
|
77
|
+
"@pothos/plugin-complexity": "4.0.0-next.0",
|
|
78
|
+
"@pothos/core": "4.0.0-next.0",
|
|
79
|
+
"@pothos/plugin-relay": "4.0.0-next.0"
|
|
80
80
|
},
|
|
81
81
|
"scripts": {
|
|
82
82
|
"generate": "prisma generate",
|
package/src/generator.ts
CHANGED
|
@@ -119,7 +119,7 @@ async function generateOutput(
|
|
|
119
119
|
prismaLocation: string,
|
|
120
120
|
outputLocation: string,
|
|
121
121
|
config: GeneratorConfig,
|
|
122
|
-
datamodel
|
|
122
|
+
datamodel?: 'esm' | 'cjs',
|
|
123
123
|
) {
|
|
124
124
|
const prismaImportStatement = ts.factory.createImportDeclaration(
|
|
125
125
|
...modifiersArg,
|
|
@@ -194,7 +194,7 @@ async function generateOutput(
|
|
|
194
194
|
);
|
|
195
195
|
|
|
196
196
|
const nodes = ts.factory.createNodeArray(
|
|
197
|
-
config.generateDatamodel === 'true'
|
|
197
|
+
config.generateDatamodel === 'true'
|
|
198
198
|
? [prismaImportStatement, dmmfImportStatement, prismaTypes, dmmfExport]
|
|
199
199
|
: [prismaImportStatement, prismaTypes],
|
|
200
200
|
);
|
|
@@ -204,18 +204,20 @@ async function generateOutput(
|
|
|
204
204
|
mkdirSync(dirname(sourcefile.fileName), { recursive: true });
|
|
205
205
|
writeFileSync(sourcefile.fileName, `/* eslint-disable */\n${result}`);
|
|
206
206
|
|
|
207
|
-
if (
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
207
|
+
if (outputLocation.endsWith('.d.ts')) {
|
|
208
|
+
if (config.generateDatamodel === 'true' && datamodel === 'cjs') {
|
|
209
|
+
writeFileSync(
|
|
210
|
+
outputLocation.replace(/\.d\.ts$/, '.js'),
|
|
211
|
+
`/* eslint-disable */\nmodule.exports = { getDatamodel: () => JSON.parse(${JSON.stringify(JSON.stringify(trimmedDatamodel))}) }\n`,
|
|
212
|
+
);
|
|
213
|
+
}
|
|
213
214
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
215
|
+
if (config.generateDatamodel === 'true' && datamodel === 'esm') {
|
|
216
|
+
writeFileSync(
|
|
217
|
+
outputLocation.replace(/\.d\.ts$/, '.js'),
|
|
218
|
+
`/* eslint-disable */\nexport function getDatamodel() { return JSON.parse(${JSON.stringify(JSON.stringify(trimmedDatamodel))}) }\n`,
|
|
219
|
+
);
|
|
220
|
+
}
|
|
219
221
|
}
|
|
220
222
|
}
|
|
221
223
|
|