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