prisma-nestjs-graphql 22.0.1 → 23.0.0

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/README.md CHANGED
@@ -86,13 +86,13 @@ Default: `''` (empty string)
86
86
 
87
87
  Combine nested/nullable scalar filters to single
88
88
  Type: `boolean`
89
- Default: `false`
89
+ Default: `true`
90
90
 
91
91
  #### `noAtomicOperations`
92
92
 
93
93
  Remove input types for atomic operations
94
94
  Type: `boolean`
95
- Default: `false`
95
+ Default: `true`
96
96
 
97
97
  #### `reExport`
98
98
 
@@ -788,12 +788,11 @@ import { generate } from 'prisma-nestjs-graphql';
788
788
 
789
789
  ## TODO
790
790
 
791
- - fin Use relation type here and fix
792
- - run example, get rid of node-dev
793
- - keyof typeof SortOrder -> `SortOrder`
791
+ - noAtomicOperations = 1, IntFieldUpdateOperationsInput exists
792
+ - CommentUncheckedUpdateManyWithoutAuthorNestedInput and CommentUpdateManyWithoutAuthorNestedInput are same
793
+ - Add logic to detect view models and skip generation of mutation inputs/args for them https://github.com/unlight/prisma-nestjs-graphql/issues/248
794
794
  - dummy-createfriends.input.ts -> `create-friends`
795
795
  - check 'TODO FIXME'
796
- - 22.12 node require esm (update all deps to latest)
797
796
 
798
797
  ## License
799
798
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "prisma-nestjs-graphql",
3
3
  "type": "module",
4
- "version": "22.0.1",
4
+ "version": "23.0.0",
5
5
  "license": "MIT",
6
6
  "description": "Generate object types, inputs, args, etc. from prisma schema file for usage with @nestjs/graphql module",
7
7
  "bin": "bin.mjs",
@@ -138,7 +138,7 @@ function beforeInputType$2(args) {
138
138
  inputType.name = replaceBogus(inputType.name);
139
139
  }
140
140
  }
141
- function beforeGenerateField(field) {
141
+ function beforeGenerateField(field, args) {
142
142
  for (const fieldInput of field.inputTypes) {
143
143
  if (fieldInput.location !== 'inputObjectTypes') {
144
144
  continue;
@@ -175,13 +175,7 @@ function postBegin(args) {
175
175
  } = args;
176
176
  const inputTypes = schema.inputObjectTypes.prisma ?? [];
177
177
  const enumTypes = schema.enumTypes.model || [];
178
- const types = ['Bool', 'Int', 'String', 'DateTime', 'Decimal', 'Float', 'Json', 'Bytes', 'BigInt'];
179
- for (const enumType of enumTypes) {
180
- const {
181
- name
182
- } = enumType;
183
- types.push(`Enum${name}`);
184
- }
178
+ const types = ['Bool', 'Int', 'String', 'DateTime', 'Decimal', 'Float', 'Json', 'Bytes', 'BigInt', ...enumTypes.map(x => `Enum${x.name}`)];
185
179
  const inputTypeByName = keyBy(inputTypes, inputType => inputType.name);
186
180
  const replaceBogusFilters = (filterName, filterNameCandidates) => {
187
181
  for (const filterNameCandidate of filterNameCandidates) {
@@ -199,9 +193,9 @@ function postBegin(args) {
199
193
  };
200
194
  for (const type of types) {
201
195
  // Scalar filters
202
- replaceBogusFilters(`${type}Filter`, [`${type}NullableFilter`, `Nested${type}NullableFilter`]);
203
- replaceBogusFilters(`${type}WithAggregatesFilter`, [`${type}NullableWithAggregatesFilter`, `Nested${type}NullableWithAggregatesFilter`]);
204
- replaceBogusFilters(`${type}ListFilter`, [`${type}NullableListFilter`, `Nested${type}NullableListFilter`]);
196
+ replaceBogusFilters(`${type}Filter`, [`${type}NullableFilter`, `Nested${type}NullableFilter`, `Nested${type}Filter`]);
197
+ replaceBogusFilters(`${type}WithAggregatesFilter`, [`${type}NullableWithAggregatesFilter`, `Nested${type}NullableWithAggregatesFilter`, `Nested${type}WithAggregatesFilter`]);
198
+ replaceBogusFilters(`${type}ListFilter`, [`${type}NullableListFilter`, `Nested${type}NullableListFilter`, `Nested${type}ListFilter`]);
205
199
  }
206
200
  for (const modelName of modelNames) {
207
201
  replaceBogusFilters(`${modelName}RelationFilter`, [`${modelName}NullableRelationFilter`]);
@@ -471,7 +465,7 @@ function combineToSingle(args) {
471
465
  });
472
466
  }
473
467
 
474
- const extensions = new Set(['.js', '.mjs', '.ts', '.mts']);
468
+ const extensions = new Set(['.js', '.mjs', '.ts', '.mts', '.cts', '.cjs']);
475
469
  function adjustModuleSpecifier(moduleSpecifier, importExtension) {
476
470
  if (moduleSpecifier.startsWith('.')) {
477
471
  let specifierWithoutExtension = moduleSpecifier;
@@ -840,11 +834,6 @@ function inputType(args) {
840
834
  });
841
835
  const useInputType = config.useInputType.find(x => inputType.name.includes(x.typeName));
842
836
  const isWhereUnique = isWhereUniqueInputType(inputType.name);
843
-
844
- // if (inputType.name.includes('DecimalNullableFilter')) {
845
- // console.log({ importDeclarations, location, property, propertyType });
846
- // }
847
-
848
837
  for (const field of inputType.fields) {
849
838
  field.inputTypes = field.inputTypes.filter(t => !removeTypes.has(String(t.type)));
850
839
  eventEmitter.emitSync(BeforeGenerateField, field, args);
@@ -1969,7 +1958,7 @@ function createConfig(data) {
1969
1958
  delimiter: '_'
1970
1959
  }));
1971
1960
  const $warnings = [];
1972
- const configOutputFilePattern = String(config.outputFilePattern || `{model}/{name}.{type}.ts`);
1961
+ const configOutputFilePattern = typeof config.outputFilePattern === 'string' && config.outputFilePattern || `{model}/{name}.{type}.ts`;
1973
1962
  const outputFilePattern = configOutputFilePattern.replaceAll('\\', '/').split('/').map(path => filenamify(path, {
1974
1963
  replacement: ''
1975
1964
  })).filter(Boolean).join('/');
@@ -2025,7 +2014,7 @@ function createConfig(data) {
2025
2014
  }
2026
2015
  return {
2027
2016
  $warnings,
2028
- combineScalarFilters: toBoolean(config.combineScalarFilters),
2017
+ combineScalarFilters: toBoolean(config.combineScalarFilters ?? 'true'),
2029
2018
  customImport,
2030
2019
  decorate,
2031
2020
  emitBlocks: createEmitBlocks(config.emitBlocks),
@@ -2033,8 +2022,8 @@ function createConfig(data) {
2033
2022
  emitSingle: toBoolean(config.emitSingle),
2034
2023
  fields,
2035
2024
  graphqlScalars: config.graphqlScalars || {},
2036
- importExtension: String(config.importExtension ?? ''),
2037
- noAtomicOperations: toBoolean(config.noAtomicOperations),
2025
+ importExtension: typeof config.importExtension === 'string' && config.importExtension || '',
2026
+ noAtomicOperations: toBoolean(config.noAtomicOperations ?? 'true'),
2038
2027
  noTypeId: toBoolean(config.noTypeId),
2039
2028
  omitModelsCount: toBoolean(config.omitModelsCount),
2040
2029
  outputFilePattern,