prisma-nestjs-graphql
Advanced tools
Comparing version 14.3.0 to 14.4.0
71
index.js
@@ -576,3 +576,6 @@ var __create = Object.create; | ||
const settings = modelFieldSettings == null ? void 0 : modelFieldSettings.get(name); | ||
const propertySettings = settings == null ? void 0 : settings.getPropertyType(); | ||
const propertySettings = settings == null ? void 0 : settings.getPropertyType({ | ||
name: inputType2.name, | ||
input: true | ||
}); | ||
const isCustomsApplicable = typeName === ((_a = model == null ? void 0 : model.fields.find((f) => f.name === name)) == null ? void 0 : _a.type); | ||
@@ -599,4 +602,7 @@ const propertyType = (0, import_lodash3.castArray)((propertySettings == null ? void 0 : propertySettings.name) || getPropertyType({ | ||
let graphqlType; | ||
const fieldType = settings == null ? void 0 : settings.getFieldType(); | ||
if (fieldType && fieldType.input && isCustomsApplicable) { | ||
const fieldType = settings == null ? void 0 : settings.getFieldType({ | ||
name: inputType2.name, | ||
input: true | ||
}); | ||
if (fieldType && isCustomsApplicable) { | ||
graphqlType = fieldType.name; | ||
@@ -676,7 +682,31 @@ importDeclarations.create(__spreadValues({}, fieldType)); | ||
} | ||
getFieldType() { | ||
return this.find((s) => s.kind === "FieldType"); | ||
getFieldType({ | ||
name, | ||
input, | ||
output | ||
}) { | ||
const fieldType = this.find((s) => s.kind === "FieldType"); | ||
if (!fieldType) { | ||
return void 0; | ||
} | ||
if (fieldType.match) { | ||
return fieldType.match(name) ? fieldType : void 0; | ||
} | ||
if (input && !fieldType.input) { | ||
return void 0; | ||
} | ||
if (output && !fieldType.output) { | ||
return void 0; | ||
} | ||
return fieldType; | ||
} | ||
getPropertyType() { | ||
return this.find((s) => s.kind === "PropertyType"); | ||
getPropertyType({ name }) { | ||
const propertyType = this.find((s) => s.kind === "PropertyType"); | ||
if (!propertyType) { | ||
return void 0; | ||
} | ||
if (propertyType.match && !propertyType.match(name)) { | ||
return void 0; | ||
} | ||
return propertyType; | ||
} | ||
@@ -768,2 +798,5 @@ getObjectTypeArguments(options) { | ||
} | ||
if (typeof options.match === "string" || Array.isArray(options.match)) { | ||
result.match = (0, import_outmatch2.default)(options.match, { separator: false }); | ||
} | ||
return result; | ||
@@ -911,4 +944,10 @@ } | ||
const settings = (_c = fieldSettings.get(model.name)) == null ? void 0 : _c.get(field.name); | ||
const fieldType = settings == null ? void 0 : settings.getFieldType(); | ||
const propertySettings = settings == null ? void 0 : settings.getPropertyType(); | ||
const fieldType = settings == null ? void 0 : settings.getFieldType({ | ||
name: outputType2.name, | ||
output: true | ||
}); | ||
const propertySettings = settings == null ? void 0 : settings.getPropertyType({ | ||
name: outputType2.name, | ||
output: true | ||
}); | ||
const propertyType = (0, import_lodash5.castArray)((propertySettings == null ? void 0 : propertySettings.name) || getPropertyType({ | ||
@@ -923,3 +962,3 @@ location, | ||
let graphqlType; | ||
if (fieldType && fieldType.output) { | ||
if (fieldType) { | ||
graphqlType = fieldType.name; | ||
@@ -1092,3 +1131,6 @@ importDeclarations.create(__spreadValues({}, fieldType)); | ||
const settings = isCountOutput ? void 0 : model && ((_a = fieldSettings.get(model.name)) == null ? void 0 : _a.get(field.name)); | ||
const propertySettings = settings == null ? void 0 : settings.getPropertyType(); | ||
const propertySettings = settings == null ? void 0 : settings.getPropertyType({ | ||
name: outputType2.name, | ||
output: true | ||
}); | ||
const isCustomsApplicable = outputTypeName === ((_b = model == null ? void 0 : model.fields.find((f) => f.name === field.name)) == null ? void 0 : _b.type); | ||
@@ -1116,4 +1158,7 @@ field.outputType.type = outputTypeName; | ||
let graphqlType; | ||
const fieldType = settings == null ? void 0 : settings.getFieldType(); | ||
if (fieldType && fieldType.output && isCustomsApplicable) { | ||
const fieldType = settings == null ? void 0 : settings.getFieldType({ | ||
name: outputType2.name, | ||
output: true | ||
}); | ||
if (fieldType && isCustomsApplicable) { | ||
graphqlType = fieldType.name; | ||
@@ -1120,0 +1165,0 @@ importDeclarations.create(__spreadValues({}, fieldType)); |
{ | ||
"name": "prisma-nestjs-graphql", | ||
"version": "14.3.0", | ||
"version": "14.4.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Generate object types, inputs, args, etc. from prisma schema file for usage with @nestjs/graphql module", |
@@ -425,4 +425,7 @@ # prisma-nestjs-graphql | ||
Allow set custom type for field | ||
Allow set custom GraphQL scalar type for field | ||
To override scalar type in specific classes, you can use glob pattern `match: string | string[]` | ||
see [outmatch](https://github.com/axtgr/outmatch#usage) for details. | ||
```prisma | ||
@@ -483,2 +486,5 @@ model User { | ||
To override TypeScript type in specific classes, you can use glob pattern `match: string | string[]` | ||
see [outmatch](https://github.com/axtgr/outmatch#usage) for details. | ||
Named import example: | ||
@@ -485,0 +491,0 @@ |
79783
1706
588