@nestledjs/api 2.9.3 → 2.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -202,7 +202,6 @@ function generateModels(models: readonly any[], enums: readonly any[]): string {
|
|
|
202
202
|
model.fields.some((field: { type: string }) => field.type === 'DateTime'),
|
|
203
203
|
)
|
|
204
204
|
let output = `import { Field, ObjectType${usesFloat ? ', Float' : ''}${usesDateTime ? ', GraphQLISODateTime' : ''}, Int } from '@nestjs/graphql';\n`
|
|
205
|
-
output += `import { GraphQLJSONObject } from 'graphql-type-json';\n`
|
|
206
205
|
|
|
207
206
|
// Check if any model field uses Decimal
|
|
208
207
|
const usesDecimal = models.some(model =>
|
|
@@ -212,6 +211,9 @@ function generateModels(models: readonly any[], enums: readonly any[]): string {
|
|
|
212
211
|
const usesJson = models.some(model =>
|
|
213
212
|
model.fields.some((field: { type: string }) => field.type === 'Json'),
|
|
214
213
|
)
|
|
214
|
+
if (usesJson) {
|
|
215
|
+
output += `import { GraphQLJSON } from 'graphql-type-json';\n`
|
|
216
|
+
}
|
|
215
217
|
if (usesDecimal) {
|
|
216
218
|
output += `import Decimal from 'decimal.js';\n`
|
|
217
219
|
output += `import { GraphQLDecimal } from 'prisma-graphql-type-decimal';\n`
|
|
@@ -282,7 +284,7 @@ function generateModels(models: readonly any[], enums: readonly any[]): string {
|
|
|
282
284
|
else if (originalType === 'Float') listItemGraphQLType = 'Float'
|
|
283
285
|
else if (originalType === 'Decimal') listItemGraphQLType = 'GraphQLDecimal'
|
|
284
286
|
else if (originalType === 'BigInt') listItemGraphQLType = 'GraphQLBigInt'
|
|
285
|
-
else if (originalType === 'Json') listItemGraphQLType = '
|
|
287
|
+
else if (originalType === 'Json') listItemGraphQLType = 'GraphQLJSON'
|
|
286
288
|
else if (isEnum || isRelation)
|
|
287
289
|
listItemGraphQLType = originalType // Assumes enum/type is registered with GraphQL
|
|
288
290
|
else if (originalType === 'DateTime') listItemGraphQLType = 'GraphQLISODateTime'
|
|
@@ -299,7 +301,7 @@ function generateModels(models: readonly any[], enums: readonly any[]): string {
|
|
|
299
301
|
else if (originalType === 'Float') decoratorType = '() => Float'
|
|
300
302
|
else if (originalType === 'Decimal') decoratorType = '() => GraphQLDecimal'
|
|
301
303
|
else if (originalType === 'BigInt') decoratorType = '() => GraphQLBigInt'
|
|
302
|
-
else if (originalType === 'Json') decoratorType = '() =>
|
|
304
|
+
else if (originalType === 'Json') decoratorType = '() => GraphQLJSON'
|
|
303
305
|
else if (isEnum || isRelation) decoratorType = `() => ${originalType}`
|
|
304
306
|
else if (originalType === 'DateTime') decoratorType = '() => GraphQLISODateTime'
|
|
305
307
|
else if (originalType === 'Boolean') decoratorType = '() => Boolean'
|