prisma-nestjs-graphql
Advanced tools
Comparing version 14.2.0 to 14.2.1
84
index.js
@@ -588,22 +588,2 @@ var __create = Object.create; | ||
} | ||
let graphqlType; | ||
const fieldType = settings == null ? void 0 : settings.getFieldType(); | ||
if (fieldType && fieldType.input && isCustomsApplicable) { | ||
graphqlType = fieldType.name; | ||
importDeclarations.create(__spreadValues({}, fieldType)); | ||
} else { | ||
const graphqlImport = getGraphqlImport({ | ||
sourceFile, | ||
location, | ||
typeName, | ||
getSourceFile | ||
}); | ||
graphqlType = graphqlImport.name; | ||
if (graphqlImport.name !== inputType2.name && graphqlImport.specifier && !importDeclarations.has(graphqlImport.name)) { | ||
importDeclarations.set(graphqlImport.name, { | ||
namedImports: [{ name: graphqlImport.name }], | ||
moduleSpecifier: graphqlImport.specifier | ||
}); | ||
} | ||
} | ||
if (settings == null ? void 0 : settings.shouldHideField({ name: inputType2.name, input: true })) { | ||
@@ -614,6 +594,26 @@ importDeclarations.add("HideField", "@nestjs/graphql"); | ||
(0, import_assert2.ok)(property.decorators); | ||
let graphqlType; | ||
const fieldType = settings == null ? void 0 : settings.getFieldType(); | ||
if (fieldType && fieldType.input && isCustomsApplicable) { | ||
graphqlType = fieldType.name; | ||
importDeclarations.create(__spreadValues({}, fieldType)); | ||
} else { | ||
const graphqlImport = getGraphqlImport({ | ||
sourceFile, | ||
location, | ||
typeName, | ||
getSourceFile | ||
}); | ||
graphqlType = graphqlImport.name; | ||
if (graphqlImport.name !== inputType2.name && graphqlImport.specifier && !importDeclarations.has(graphqlImport.name)) { | ||
importDeclarations.set(graphqlImport.name, { | ||
namedImports: [{ name: graphqlImport.name }], | ||
moduleSpecifier: graphqlImport.specifier | ||
}); | ||
} | ||
} | ||
property.decorators.push({ | ||
name: "Field", | ||
arguments: [ | ||
`() => ${isList ? `[${graphqlType}]` : graphqlType}`, | ||
isList ? `() => [${graphqlType}]` : `() => ${graphqlType}`, | ||
import_json5.default.stringify({ | ||
@@ -842,3 +842,3 @@ nullable: !isRequired | ||
function getOutputTypeName(name) { | ||
return name.replace(/(OutputType|Output)$/, ""); | ||
return name.replace(/(?:OutputType|Output)$/, ""); | ||
} | ||
@@ -1044,3 +1044,3 @@ | ||
var _a, _b, _c, _d; | ||
const { getSourceFile, models, config, eventEmitter, fieldSettings, getModelName: getModelName2 } = args; | ||
const { getSourceFile, models, eventEmitter, fieldSettings, getModelName: getModelName2 } = args; | ||
const importDeclarations = new ImportDeclarationMap(); | ||
@@ -1050,3 +1050,3 @@ const fileType = "output"; | ||
const model = models.get(modelName); | ||
const isAggregateOutput = model && /(Count|Avg|Sum|Min|Max)AggregateOutputType$/.test(outputType2.name) && String(outputType2.name).startsWith(model.name); | ||
const isAggregateOutput = model && /(?:Count|Avg|Sum|Min|Max)AggregateOutputType$/.test(outputType2.name) && String(outputType2.name).startsWith(model.name); | ||
const isCountOutput = (model == null ? void 0 : model.name) && outputType2.name === `${model.name}CountOutputType`; | ||
@@ -1096,14 +1096,2 @@ outputType2.name = getOutputTypeName(outputType2.name); | ||
} | ||
const graphqlImport = getGraphqlImport({ | ||
sourceFile, | ||
fileType, | ||
location, | ||
isId: false, | ||
typeName: outputTypeName, | ||
getSourceFile | ||
}); | ||
const graphqlType = graphqlImport.name; | ||
if (graphqlImport.name !== outputType2.name && graphqlImport.specifier) { | ||
importDeclarations.add(graphqlImport.name, graphqlImport.specifier); | ||
} | ||
if (settings == null ? void 0 : settings.shouldHideField({ name: outputType2.name, output: true })) { | ||
@@ -1114,6 +1102,28 @@ importDeclarations.add("HideField", nestjsGraphql2); | ||
(0, import_assert4.ok)(property.decorators, "Missing property.decorators"); | ||
let graphqlType; | ||
const fieldType = settings == null ? void 0 : settings.getFieldType(); | ||
if (fieldType && fieldType.output && isCustomsApplicable) { | ||
graphqlType = fieldType.name; | ||
importDeclarations.create(__spreadValues({}, fieldType)); | ||
} else { | ||
const graphqlImport = getGraphqlImport({ | ||
sourceFile, | ||
fileType, | ||
location, | ||
isId: false, | ||
typeName: outputTypeName, | ||
getSourceFile | ||
}); | ||
graphqlType = graphqlImport.name; | ||
if (graphqlImport.name !== outputType2.name && graphqlImport.specifier && !importDeclarations.has(graphqlImport.name)) { | ||
importDeclarations.set(graphqlImport.name, { | ||
namedImports: [{ name: graphqlImport.name }], | ||
moduleSpecifier: graphqlImport.specifier | ||
}); | ||
} | ||
} | ||
property.decorators.push({ | ||
name: "Field", | ||
arguments: [ | ||
`() => ${isList ? `[${graphqlType}]` : graphqlType}`, | ||
isList ? `() => [${graphqlType}]` : `() => ${graphqlType}`, | ||
import_json54.default.stringify({ | ||
@@ -1120,0 +1130,0 @@ nullable: Boolean(field.isNullable) |
{ | ||
"name": "prisma-nestjs-graphql", | ||
"version": "14.2.0", | ||
"version": "14.2.1", | ||
"license": "MIT", | ||
@@ -62,3 +62,2 @@ "description": "Generate object types, inputs, args, etc. from prisma schema file for usage with @nestjs/graphql module", | ||
}, | ||
"peerDependencies": {}, | ||
"devDependencies": { | ||
@@ -76,3 +75,2 @@ "@arkweid/lefthook": "0.7.6", | ||
"@semantic-release/git": "^10.0.0", | ||
"@types/find-cache-dir": "^3.2.1", | ||
"@types/flat": "^5.0.2", | ||
@@ -107,3 +105,2 @@ "@types/lodash": "^4.14.173", | ||
"expect": "^27.2.1", | ||
"find-cache-dir": "^3.3.2", | ||
"git-branch-is": "^4.0.0", | ||
@@ -123,2 +120,3 @@ "graphql": "^15.6.0", | ||
"simplytyped": "^3.3.0", | ||
"temp-dir": "^2.0.0", | ||
"ts-node": "^10.2.1", | ||
@@ -125,0 +123,0 @@ "ts-node-dev": "^1.1.8", |
@@ -525,3 +525,3 @@ # prisma-nestjs-graphql | ||
Allow rename type in schema and make mark as abstract. | ||
Allow rename type in schema and mark as abstract. | ||
@@ -528,0 +528,0 @@ Example 1: |
77139
60
1626