prisma-nestjs-graphql 15.2.3 → 15.2.6

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.
Files changed (3) hide show
  1. package/README.md +23 -0
  2. package/index.js +8 -7
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -281,6 +281,29 @@ data!: UserCreateInput;
281
281
 
282
282
  ```
283
283
 
284
+ Add `@HideField()` decorator to nested types:
285
+
286
+ ```
287
+ decorate_3_type = "*CreateNestedOneWithoutUserInput"
288
+ decorate_3_field = "!(create)"
289
+ decorate_3_name = "HideField"
290
+ decorate_3_from = "@nestjs/graphql"
291
+ decorate_3_arguments = "[]"
292
+ ```
293
+
294
+ May generate following class:
295
+
296
+ ```ts
297
+ @Field(() => ProfileCreateWithoutUserInput, { nullable: true })
298
+ create?: ProfileCreateWithoutUserInput;
299
+
300
+ @HideField()
301
+ connectOrCreate?: ProfileCreateOrConnectWithoutUserInput;
302
+
303
+ @HideField()
304
+ connect?: ProfileWhereUniqueInput;
305
+ ```
306
+
284
307
  #### `graphqlScalars`
285
308
 
286
309
  Allow to set custom graphql type for Prisma scalar type.
package/index.js CHANGED
@@ -494,6 +494,7 @@ function getGraphqlInputType(inputTypes, pattern) {
494
494
  "null",
495
495
  "Null"
496
496
  ].includes(String(t.type)));
497
+ inputTypes = (0, import_lodash2.uniqWith)(inputTypes, import_lodash2.isEqual);
497
498
  if (inputTypes.length === 1) {
498
499
  return inputTypes[0];
499
500
  }
@@ -694,14 +695,14 @@ function inputType(args) {
694
695
  importDeclarations.create({
695
696
  ...propertySettings
696
697
  });
697
- } else if (!propertySettings && propertyType.includes("Decimal")) {
698
+ } else if (propertyType.includes("Decimal")) {
698
699
  importDeclarations.add("Decimal", "@prisma/client/runtime");
699
700
  }
700
701
  let graphqlType;
701
- const shouldHideField = settings == null ? void 0 : settings.shouldHideField({
702
+ const shouldHideField = (settings == null ? void 0 : settings.shouldHideField({
702
703
  name: inputType1.name,
703
704
  input: true
704
- });
705
+ })) || config.decorate.some((d) => d.name === "HideField" && d.from === "@nestjs/graphql" && d.isMatchField(name) && d.isMatchType(inputType1.name));
705
706
  const fieldType = settings == null ? void 0 : settings.getFieldType({
706
707
  name: inputType1.name,
707
708
  input: true
@@ -724,7 +725,7 @@ function inputType(args) {
724
725
  if (location === "enumTypes") {
725
726
  referenceName = (0, import_lodash3.last)(referenceName.split(" "));
726
727
  }
727
- if (graphqlImport.specifier && !importDeclarations.has(graphqlImport.name) && (graphqlImport.name !== inputType1.name && !shouldHideField || shouldHideField && referenceName === graphqlImport.name)) {
728
+ if (graphqlImport.specifier && !importDeclarations.has(graphqlImport.name) && graphqlImport.name !== inputType1.name) {
728
729
  importDeclarations.set(graphqlImport.name, {
729
730
  namedImports: [
730
731
  {
@@ -1356,14 +1357,14 @@ function outputType(outputType1, args) {
1356
1357
  importDeclarations.create({
1357
1358
  ...propertySettings
1358
1359
  });
1359
- } else if (!propertySettings && propertyType.includes("Decimal")) {
1360
+ } else if (propertyType.includes("Decimal")) {
1360
1361
  importDeclarations.add("Decimal", "@prisma/client/runtime");
1361
1362
  }
1362
1363
  let graphqlType;
1363
- const shouldHideField = settings == null ? void 0 : settings.shouldHideField({
1364
+ const shouldHideField = (settings == null ? void 0 : settings.shouldHideField({
1364
1365
  name: outputType1.name,
1365
1366
  output: true
1366
- });
1367
+ })) || config.decorate.some((d) => d.name === "HideField" && d.from === "@nestjs/graphql" && d.isMatchField(field.name) && d.isMatchType(outputTypeName));
1367
1368
  const fieldType = settings == null ? void 0 : settings.getFieldType({
1368
1369
  name: outputType1.name,
1369
1370
  output: true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prisma-nestjs-graphql",
3
- "version": "15.2.3",
3
+ "version": "15.2.6",
4
4
  "license": "MIT",
5
5
  "description": "Generate object types, inputs, args, etc. from prisma schema file for usage with @nestjs/graphql module",
6
6
  "main": "index.js",
@@ -25,7 +25,7 @@
25
25
  "mocha": "node node_modules/mocha/bin/mocha",
26
26
  "test:r": "npm run mocha -- -r ts-node/register src/**/*.spec.ts",
27
27
  "test:cov": "c8 --reporter text --exclude \"**/*.spec.ts\" --exclude \"**/test/**\" npm run test:r -- --no-timeouts",
28
- "test:w": "npm run test:r -- --watch-files src --watch",
28
+ "test:w": "npm run test:r -- --watch-files src --watch --timeout=10s",
29
29
  "test:d": "ndb -r @swc/register node_modules/mocha/bin/_mocha --no-timeouts --watch-files src/**/*.ts --watch src/**/*.spec.ts",
30
30
  "tscheck": "tsc --noEmit",
31
31
  "tscheck:w": "npm run tscheck -- --watch",