Skip to content

Commit a075e00

Browse files
committed
fix(custom decorators): FieldType respect input/output in generator settings
close: #34
1 parent 55fa066 commit a075e00

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

src/handlers/input-type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export function inputType(
111111
let graphqlType: string;
112112
const fieldType = settings?.getFieldType();
113113

114-
if (fieldType && isCustomsApplicable) {
114+
if (fieldType && fieldType.input && isCustomsApplicable) {
115115
graphqlType = fieldType.name;
116116
importDeclarations.create({ ...fieldType });
117117
} else {

src/handlers/model-output-type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export function modelOutputType(outputType: OutputType, args: EventArguments) {
119119

120120
let graphqlType: string;
121121

122-
if (fieldType) {
122+
if (fieldType && fieldType.output) {
123123
graphqlType = fieldType.name;
124124
importDeclarations.create({ ...fieldType });
125125
} else {

src/test/custom-decorators.spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,31 @@ describe('custom decorators namespace both input and output', () => {
339339
});
340340
});
341341

342+
describe('fieldtype disable output', () => {
343+
before(async () => {
344+
({ project, sourceFiles } = await testGenerate({
345+
schema: `
346+
model User {
347+
id String @id @default(cuid())
348+
/// @FieldType('Upload.GraphQLUpload')
349+
image String?
350+
}
351+
`,
352+
options: [
353+
`outputFilePattern = "{name}.{type}.ts"`,
354+
`fields_Upload_from = "graphql-upload"`,
355+
`fields_Upload_input = true`,
356+
`fields_Upload_output = false`,
357+
],
358+
}));
359+
});
360+
361+
it('upload image output', () => {
362+
setSourceFile('user.model.ts');
363+
expect(t('image')).toEqual('() => String');
364+
});
365+
});
366+
342367
describe('custom decorators and description', () => {
343368
before(async () => {
344369
({ project, sourceFiles } = await testGenerate({

0 commit comments

Comments
 (0)