eslint-plugin-prisma-nestjs-graphql
Advanced tools
Comparing version 0.0.6 to 0.1.0
@@ -49,3 +49,5 @@ "use strict"; | ||
const args = (name, type) => { | ||
return `@Args({ name: '${name}', nullable: true }) ${name}: ${type}OrderByInput,`; | ||
return `@Args({ nullable: true }) ${name}: FindMany${type | ||
.replace('[', '') | ||
.replace(']', '')}Args`; | ||
}; | ||
@@ -104,8 +106,9 @@ module.exports = { | ||
const multiImports = openResolvers | ||
.filter(i => -1 !== i.type.search('[')) | ||
.filter(i => -1 !== i.type.indexOf('[')) | ||
.map(r => r.type.replace('[', '').replace(']', '')); | ||
const importFix = fixer.insertTextBefore(decorator, `import { | ||
${imports.join(', ')}, | ||
${multiImports.map(i => i + 'WhereInput').join(', ')}, | ||
${multiImports.map(i => i + 'OrderByInput').join(', ')}, | ||
${multiImports | ||
.map(i => 'FindMany' + i + 'Args, ') | ||
.join('')} | ||
} from '@prisma/client/nestjs-graphql' | ||
@@ -119,11 +122,5 @@ `); | ||
@ResolveField(() => ${r.type}, { | ||
name: '${r.name}', | ||
${isToManyRelation ? '' : '\n nullable: true,'} | ||
name: '${r.name}',${isToManyRelation ? '' : '\n nullable: true, \n'} | ||
}) | ||
${r.name}(@Parent() ${(0, camelcase_1.default)(decoratorName)}: ${decoratorName}, ${isToManyRelation | ||
? args('where', r.type) + | ||
', \n' + | ||
args('orderBy', r.type) | ||
: ''} | ||
) { | ||
${r.name}(@Parent() ${(0, camelcase_1.default)(decoratorName)}: ${decoratorName}, ${isToManyRelation ? args('args', r.type) + ', ' : ''}) { | ||
return this.${(0, camelcase_1.default)(decoratorName)}Service | ||
@@ -133,5 +130,5 @@ .findOne({ | ||
}) | ||
.${r.name}({ where }); | ||
.${r.name}(${isToManyRelation ? 'args' : ''}); | ||
} | ||
`; | ||
`; | ||
}) | ||
@@ -138,0 +135,0 @@ .join(''); |
{ | ||
"name": "eslint-plugin-prisma-nestjs-graphql", | ||
"version": "0.0.6", | ||
"version": "0.1.0", | ||
"description": "eslint plugin for prisma & nestjs & graphql setups to not forget resolvers etc.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35831
142