@pegasusheavy/nestjs-prisma-graphql 1.4.1 → 1.4.3
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/dist/generate.js +21 -6
- package/dist/generate.js.map +1 -1
- package/dist/index.js +21 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/generate.js
CHANGED
|
@@ -585,13 +585,16 @@ function getGraphqlImport(args) {
|
|
|
585
585
|
if (sourceFileType === "output" && fileType === "model") {
|
|
586
586
|
sourceFileType = "model";
|
|
587
587
|
}
|
|
588
|
-
|
|
588
|
+
let specifier = relativePath(
|
|
589
589
|
sourceFile.getFilePath(),
|
|
590
590
|
getSourceFile({
|
|
591
591
|
name: typeName,
|
|
592
592
|
type: sourceFileType
|
|
593
593
|
}).getFilePath()
|
|
594
594
|
);
|
|
595
|
+
if (config.esmCompatible && !specifier.startsWith("@") && !specifier.endsWith(".js")) {
|
|
596
|
+
specifier += ".js";
|
|
597
|
+
}
|
|
595
598
|
return { name: typeName, specifier };
|
|
596
599
|
}
|
|
597
600
|
function getGraphqlInputType(inputTypes, pattern) {
|
|
@@ -785,10 +788,13 @@ function inputType(args) {
|
|
|
785
788
|
namedImports: [{ name: classDecoratorName }]
|
|
786
789
|
});
|
|
787
790
|
if (config.esmCompatible) {
|
|
788
|
-
|
|
791
|
+
let typeRegistryPath = relativePath(
|
|
789
792
|
sourceFile.getFilePath(),
|
|
790
793
|
`${output}/type-registry.ts`
|
|
791
794
|
);
|
|
795
|
+
if (!typeRegistryPath.endsWith(".js")) {
|
|
796
|
+
typeRegistryPath += ".js";
|
|
797
|
+
}
|
|
792
798
|
importDeclarations.add("registerType", typeRegistryPath);
|
|
793
799
|
importDeclarations.add("getType", typeRegistryPath);
|
|
794
800
|
}
|
|
@@ -917,10 +923,13 @@ function inputType(args) {
|
|
|
917
923
|
name: "Field"
|
|
918
924
|
});
|
|
919
925
|
if (graphqlType === "GraphQLDecimal") {
|
|
920
|
-
|
|
926
|
+
let decimalHelpersPath = relativePath(
|
|
921
927
|
sourceFile.getFilePath(),
|
|
922
928
|
`${output}/decimal-helpers.ts`
|
|
923
929
|
);
|
|
930
|
+
if (config.esmCompatible && !decimalHelpersPath.endsWith(".js")) {
|
|
931
|
+
decimalHelpersPath += ".js";
|
|
932
|
+
}
|
|
924
933
|
importDeclarations.add("transformToDecimal", decimalHelpersPath);
|
|
925
934
|
importDeclarations.add("Transform", "class-transformer");
|
|
926
935
|
importDeclarations.add("Type", "class-transformer");
|
|
@@ -1479,10 +1488,13 @@ function modelOutputType(outputType2, args) {
|
|
|
1479
1488
|
importDeclarations.add("ObjectType", nestjsGraphql);
|
|
1480
1489
|
const lazyTypes = /* @__PURE__ */ new Set();
|
|
1481
1490
|
if (config.esmCompatible) {
|
|
1482
|
-
|
|
1491
|
+
let typeRegistryPath = relativePath(
|
|
1483
1492
|
sourceFile.getFilePath(),
|
|
1484
1493
|
`${output}/type-registry.ts`
|
|
1485
1494
|
);
|
|
1495
|
+
if (!typeRegistryPath.endsWith(".js")) {
|
|
1496
|
+
typeRegistryPath += ".js";
|
|
1497
|
+
}
|
|
1486
1498
|
importDeclarations.add("registerType", typeRegistryPath);
|
|
1487
1499
|
importDeclarations.add("getType", typeRegistryPath);
|
|
1488
1500
|
}
|
|
@@ -1534,7 +1546,7 @@ function modelOutputType(outputType2, args) {
|
|
|
1534
1546
|
if (graphqlImport.name !== outputType2.name && graphqlImport.specifier !== null && graphqlImport.specifier !== void 0 && graphqlImport.specifier.length > 0) {
|
|
1535
1547
|
const isCircular = config.esmCompatible && location === "outputObjectTypes" && namespace === "model" && hasCircularDependency(circularDependencies, outputType2.name, outputTypeName);
|
|
1536
1548
|
if (isCircular) {
|
|
1537
|
-
importDeclarations.
|
|
1549
|
+
importDeclarations.add(graphqlImport.name, graphqlImport.specifier);
|
|
1538
1550
|
lazyTypes.add(graphqlImport.name);
|
|
1539
1551
|
useGetType = true;
|
|
1540
1552
|
} else {
|
|
@@ -2003,7 +2015,10 @@ function generateRegisterAllTypes(args) {
|
|
|
2003
2015
|
const fileText = file.getText();
|
|
2004
2016
|
const registerMatch = /registerType\(['"]([^'"]+)['"]/.exec(fileText);
|
|
2005
2017
|
if (registerMatch) {
|
|
2006
|
-
|
|
2018
|
+
let relPath = relativePath(sourceFile.getFilePath(), filePath);
|
|
2019
|
+
if (!relPath.endsWith(".js")) {
|
|
2020
|
+
relPath += ".js";
|
|
2021
|
+
}
|
|
2007
2022
|
importPaths.push(relPath);
|
|
2008
2023
|
typeNames.push(registerMatch[1]);
|
|
2009
2024
|
}
|