prisma-nestjs-graphql
Advanced tools
Comparing version 4.0.1 to 5.0.0
63
index.js
@@ -179,4 +179,3 @@ "use strict"; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var __assign = Object.assign; | ||
function generateFileName(args) { | ||
const {type, name, models} = args; | ||
const template = args.template || "{feature}/{name}.{type}.ts"; | ||
const {template, type, name, models} = args; | ||
return _pupa2.default.call(void 0, template, { | ||
@@ -330,16 +329,11 @@ type, | ||
let classDeclaration = sourceFile.getClasses().find((classDeclaration2) => classDeclaration2.getName() === name); | ||
if (!classDeclaration) { | ||
classDeclaration = sourceFile.addClass({ | ||
name, | ||
isExported: true, | ||
decorators: [{name: decorator.name, arguments: []}] | ||
}); | ||
if (classDeclaration) { | ||
classDeclaration.remove(); | ||
} | ||
let decoratorDeclaration = classDeclaration.getDecorators().find((d) => d.getName() === decorator.name); | ||
if (!decoratorDeclaration) { | ||
decoratorDeclaration = classDeclaration.addDecorator({ | ||
name: decorator.name, | ||
arguments: [] | ||
}); | ||
} | ||
classDeclaration = sourceFile.addClass({ | ||
name, | ||
isExported: true, | ||
decorators: [{name: decorator.name, arguments: []}] | ||
}); | ||
const decoratorDeclaration = classDeclaration.getDecorators().find((d) => d.getName() === decorator.name); | ||
_assert2.default.call(void 0, decoratorDeclaration); | ||
@@ -365,15 +359,10 @@ const callExpression = decoratorDeclaration.getCallExpression(); | ||
const {type, isRequired, name, classDeclaration, isReadOnly} = args; | ||
let propertyDeclaration = classDeclaration.getProperties().find((propertyDeclaration2) => propertyDeclaration2.getName() === name); | ||
if (!propertyDeclaration) { | ||
propertyDeclaration = classDeclaration.addProperty({ | ||
leadingTrivia: "\n", | ||
name, | ||
type, | ||
hasQuestionToken: !isRequired, | ||
hasExclamationToken: isRequired, | ||
isReadonly: isReadOnly | ||
}); | ||
} | ||
_assert2.default.call(void 0, propertyDeclaration); | ||
return propertyDeclaration; | ||
return classDeclaration.addProperty({ | ||
leadingTrivia: "\n", | ||
name, | ||
type, | ||
hasQuestionToken: !isRequired, | ||
hasExclamationToken: isRequired, | ||
isReadonly: isReadOnly | ||
}); | ||
} | ||
@@ -386,16 +375,10 @@ | ||
const {description, nullable, defaultValue, fieldType, propertyDeclaration} = args; | ||
let decorator = propertyDeclaration.getDecorator("Field"); | ||
if (!decorator) { | ||
decorator = propertyDeclaration.addDecorator({ | ||
name: "Field", | ||
arguments: [`() => ${fieldType}`, "{}"] | ||
}); | ||
} | ||
_assert2.default.call(void 0, decorator); | ||
const decorator = propertyDeclaration.addDecorator({ | ||
name: "Field", | ||
arguments: [`() => ${fieldType}`, "{}"] | ||
}); | ||
const callExpression = decorator.getCallExpression(); | ||
_assert2.default.call(void 0, callExpression); | ||
let optionsExpression = callExpression.getArguments().find((node) => _tsmorph.Node.isObjectLiteralExpression(node)); | ||
if (!optionsExpression) { | ||
[optionsExpression] = callExpression.addArguments(["{}"]); | ||
} | ||
const optionsExpression = callExpression.getArguments().find((node) => _tsmorph.Node.isObjectLiteralExpression(node)); | ||
_assert2.default.call(void 0, optionsExpression); | ||
updateObjectProperty({ | ||
@@ -402,0 +385,0 @@ expression: optionsExpression, |
{ | ||
"name": "prisma-nestjs-graphql", | ||
"version": "4.0.1", | ||
"version": "5.0.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Generate object types, inputs, args, etc. from prisma schema file for usage with @nestjs/graphql module", |
@@ -9,4 +9,3 @@ # prisma-nestjs-graphql | ||
- Combines zoo of nested/nullable filters | ||
- Updates source code of existing files | ||
- Do not generate resolvers, since it's application specific | ||
- Does not generate resolvers, since it's application specific | ||
@@ -13,0 +12,0 @@ ## Install |
Sorry, the diff of this file is not supported yet
62886
1686
89