Skip to content

Commit

Permalink
chore!: Renamed config option atomicNumberOperation to `noAtomicOpe…
Browse files Browse the repository at this point in the history
…rations`

BREAKING CHANGE:
Made all options which mutates/renames types are `false`
  • Loading branch information
unlight committed Feb 28, 2021
1 parent fd88dc9 commit 6078eb9
Show file tree
Hide file tree
Showing 39 changed files with 943 additions and 101 deletions.
11 changes: 4 additions & 7 deletions .cz-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ module.exports = {
},
{
value: 'refactor',
name:
'refactor: A code change that neither fixes a bug nor adds a feature',
name: 'refactor: A code change that neither fixes a bug nor adds a feature',
},
{
value: 'perf',
Expand Down Expand Up @@ -61,14 +60,12 @@ module.exports = {
body:
'Provide a LONGER description of the change (optional). Use "|" to break new line:\n',
breaking: 'List any BREAKING CHANGES (optional):\n',
footer:
'List any ISSUES CLOSED by this change (optional). E.g.: #31, #34:\n',
confirmCommit:
'Are you sure you want to proceed with the commit above?',
footer: 'List any ISSUES CLOSED by this change (optional). E.g.: #31, #34:\n',
confirmCommit: 'Are you sure you want to proceed with the commit above?',
},

allowCustomScopes: true,
allowBreakingChanges: ['feat', 'fix'],
allowBreakingChanges: ['feat', 'fix', 'refactor', 'chore'],
// skip any questions you want
skipQuestions: ['body'],

Expand Down
41 changes: 22 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,29 @@ npx prisma generate
## Generator options

- `output` Output folder relative to this schema file
- `outputFilePattern` File pattern (default: `{feature}/{name}.{type}.ts`)
- `outputFilePattern` File pattern
Type: `string`
Default: `{feature}/{name}.{type}.ts`
Possible tokens:
- `{feature}` - model name in dashed case or 'prisma' if unknown
- `{name}` - dashed-case name of model/input/arg without suffix
- `{type}` - short type name (model, input, args, output)
- `{plural.type}` - plural short type name (models, inputs, enums)
- `combineScalarFilters` - Combine nested/nullable scalar filters to single
(default: `true`)
- `noAtomicNumberOperations` - Remove atomic number operations,
`true` (default), `false`
- `reExportAll` - create `index.ts` files for each directory with re-export,
`false` - disabled (default), `true` - enabled
- `renameZooTypes` - Remove plague words from type names ('nullabe', 'nested')
`true` - remove (default), `false` - do not remove
- `types_*` - [flatten](https://github.com/hughsk/flat) map of types

- `types_{type}_fieldType` - TypeScript type name
- `types_{type}_fieldModule` - Module to import
- `types_{type}_graphqlType` - GraphQL type name
- `types_{type}_graphqlModule` - Module to import
- `{feature}` Model name in dashed case or 'prisma' if unknown
- `{name}` Dashed-case name of model/input/arg without suffix
- `{type}` Short type name (model, input, args, output)
- `{plural.type}` Plural short type name (models, inputs, enums)
- `combineScalarFilters` Combine nested/nullable scalar filters to single
Type: `boolean`
Default: `true`
- `noAtomicOperations` Remove input types for atomic operations
Type: `boolean`
Default: `false`
- `reExportAll` Create `index.ts` files for each directory with re-export
Type: `boolean`
Default: `false`
- `types_*` - Map prisma types in [flatten](https://github.com/hughsk/flat) style

- `types_{type}_fieldType` TypeScript field type name
- `types_{type}_fieldModule` Module to import
- `types_{type}_graphqlType` GraphQL type name
- `types_{type}_graphqlModule` Module to import

Where `{type}` is prisma type in schema

Expand Down
14 changes: 14 additions & 0 deletions Taskfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@
PATH="$PWD/node_modules/.bin":$PATH
set -e

compatibilty_check() {
rm -rf src/@generated && npm run prisma:g && npm run tscheck

# Enable noAtomicOperations
sed -i 's/noAtomicOperations = false/noAtomicOperations = true/g' prisma/schema.prisma
rm -rf src/@generated && npm run prisma:g && npm run tscheck
sed -i 's/noAtomicOperations = true/noAtomicOperations = false/g' prisma/schema.prisma

# Enable combineScalarFilters
sed -i 's/combineScalarFilters = false/combineScalarFilters = true/g' prisma/schema.prisma
rm -rf src/@generated && npm run prisma:g && npm run tscheck
sed -i 's/combineScalarFilters = true/combineScalarFilters = false/g' prisma/schema.prisma
}

build() {
set -x
rm -rf dist
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"regen": "rm -rf src/@generated && npm run prisma:g && npm run lint:src:fix && npm run format",
"example": "ts-node-dev src/example/main.ts",
"clean_cache": "rm -rf node_modules/.cache",
"compatibilty_check": "sh Taskfile compatibilty_check",
"commit": "cz"
},
"config": {
Expand Down
7 changes: 5 additions & 2 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ generator client {
generator nestgraphql {
provider = "node -r ts-node/register/transpile-only src/index.ts"
output = "../src/@generated"
renameZooTypes = true
noAtomicOperations = false
combineScalarFilters = true
noAtomicNumberOperations = true
renameZooTypes = false
}

model User {
Expand Down Expand Up @@ -74,6 +74,9 @@ enum Role {

model Dummy {
id String @id
floaty Float
int Int?
float Float?
bytes Bytes?
decimal Decimal?
bigInt BigInt?
Expand Down
15 changes: 15 additions & 0 deletions src/@generated/dummy/dummy-avg-aggregate.input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@ import { Field, InputType } from '@nestjs/graphql';

@InputType()
export class DummyAvgAggregateInput {
@Field(() => Boolean, {
nullable: true,
})
floaty?: true;

@Field(() => Boolean, {
nullable: true,
})
int?: true;

@Field(() => Boolean, {
nullable: true,
})
float?: true;

@Field(() => Boolean, {
nullable: true,
})
Expand Down
15 changes: 15 additions & 0 deletions src/@generated/dummy/dummy-avg-aggregate.output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@ import { Field, Float, ObjectType } from '@nestjs/graphql';

@ObjectType()
export class DummyAvgAggregate {
@Field(() => Float, {
nullable: false,
})
floaty!: number;

@Field(() => Float, {
nullable: true,
})
int?: number;

@Field(() => Float, {
nullable: true,
})
float?: number;

@Field(() => String, {
nullable: true,
})
Expand Down
15 changes: 15 additions & 0 deletions src/@generated/dummy/dummy-count-aggregate.input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ export class DummyCountAggregateInput {
})
id?: true;

@Field(() => Boolean, {
nullable: true,
})
floaty?: true;

@Field(() => Boolean, {
nullable: true,
})
int?: true;

@Field(() => Boolean, {
nullable: true,
})
float?: true;

@Field(() => Boolean, {
nullable: true,
})
Expand Down
15 changes: 15 additions & 0 deletions src/@generated/dummy/dummy-count-aggregate.output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ export class DummyCountAggregate {
})
id?: number;

@Field(() => Int, {
nullable: false,
})
floaty!: number;

@Field(() => Int, {
nullable: true,
})
int?: number;

@Field(() => Int, {
nullable: true,
})
float?: number;

@Field(() => Int, {
nullable: true,
})
Expand Down
17 changes: 16 additions & 1 deletion src/@generated/dummy/dummy-create-many.input.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Field, InputType } from '@nestjs/graphql';
import { Field, Float, InputType, Int } from '@nestjs/graphql';
import { GraphQLJSON } from 'graphql-type-json';

@InputType()
Expand All @@ -8,6 +8,21 @@ export class DummyCreateManyInput {
})
id!: string;

@Field(() => Float, {
nullable: false,
})
floaty!: number;

@Field(() => Int, {
nullable: true,
})
int?: number;

@Field(() => Float, {
nullable: true,
})
float?: number;

@Field(() => String, {
nullable: true,
})
Expand Down
17 changes: 16 additions & 1 deletion src/@generated/dummy/dummy-create.input.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Field, InputType } from '@nestjs/graphql';
import { Field, Float, InputType, Int } from '@nestjs/graphql';
import { GraphQLJSON } from 'graphql-type-json';

@InputType()
Expand All @@ -8,6 +8,21 @@ export class DummyCreateInput {
})
id!: string;

@Field(() => Float, {
nullable: false,
})
floaty!: number;

@Field(() => Int, {
nullable: true,
})
int?: number;

@Field(() => Float, {
nullable: true,
})
float?: number;

@Field(() => String, {
nullable: true,
})
Expand Down
17 changes: 16 additions & 1 deletion src/@generated/dummy/dummy-group-by.output.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Field, ObjectType } from '@nestjs/graphql';
import { Field, Float, Int, ObjectType } from '@nestjs/graphql';
import { GraphQLJSON } from 'graphql-type-json';

import { DummyAvgAggregate } from './dummy-avg-aggregate.output';
Expand All @@ -14,6 +14,21 @@ export class DummyGroupBy {
})
id!: string;

@Field(() => Float, {
nullable: false,
})
floaty!: number;

@Field(() => Int, {
nullable: true,
})
int?: number;

@Field(() => Float, {
nullable: true,
})
float?: number;

@Field(() => String, {
nullable: true,
})
Expand Down
15 changes: 15 additions & 0 deletions src/@generated/dummy/dummy-max-aggregate.input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ export class DummyMaxAggregateInput {
})
id?: true;

@Field(() => Boolean, {
nullable: true,
})
floaty?: true;

@Field(() => Boolean, {
nullable: true,
})
int?: true;

@Field(() => Boolean, {
nullable: true,
})
float?: true;

@Field(() => Boolean, {
nullable: true,
})
Expand Down
17 changes: 16 additions & 1 deletion src/@generated/dummy/dummy-max-aggregate.output.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Field, ObjectType } from '@nestjs/graphql';
import { Field, Float, Int, ObjectType } from '@nestjs/graphql';

@ObjectType()
export class DummyMaxAggregate {
Expand All @@ -7,6 +7,21 @@ export class DummyMaxAggregate {
})
id?: string;

@Field(() => Float, {
nullable: false,
})
floaty!: number;

@Field(() => Int, {
nullable: true,
})
int?: number;

@Field(() => Float, {
nullable: true,
})
float?: number;

@Field(() => String, {
nullable: true,
})
Expand Down
15 changes: 15 additions & 0 deletions src/@generated/dummy/dummy-min-aggregate.input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ export class DummyMinAggregateInput {
})
id?: true;

@Field(() => Boolean, {
nullable: true,
})
floaty?: true;

@Field(() => Boolean, {
nullable: true,
})
int?: true;

@Field(() => Boolean, {
nullable: true,
})
float?: true;

@Field(() => Boolean, {
nullable: true,
})
Expand Down
17 changes: 16 additions & 1 deletion src/@generated/dummy/dummy-min-aggregate.output.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Field, ObjectType } from '@nestjs/graphql';
import { Field, Float, Int, ObjectType } from '@nestjs/graphql';

@ObjectType()
export class DummyMinAggregate {
Expand All @@ -7,6 +7,21 @@ export class DummyMinAggregate {
})
id?: string;

@Field(() => Float, {
nullable: false,
})
floaty!: number;

@Field(() => Int, {
nullable: true,
})
int?: number;

@Field(() => Float, {
nullable: true,
})
float?: number;

@Field(() => String, {
nullable: true,
})
Expand Down
Loading

0 comments on commit 6078eb9

Please sign in to comment.