Skip to content

Commit

Permalink
Support omiting input fields
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalLytek committed Sep 1, 2021
1 parent 8cdb7e6 commit e7a1184
Show file tree
Hide file tree
Showing 31 changed files with 399 additions and 159 deletions.
21 changes: 20 additions & 1 deletion docs/advanced/hiding-field.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,23 @@ input UserCreateInput {
}
```

This behavior is temporary and will be improved soon by introducing `input: true` option to `@TypeGraphQL.omit`.
In order to hide the input fields as well, you need to provide the `input: true` option to `@TypeGraphQL.omit`:

```prisma {4}
model User {
id Int @default(autoincrement()) @id
email String @unique
/// @TypeGraphQL.omit(output: true, input: true)
password String
posts Post[]
}
```

So that the field won't show anymore in all model-related input types, like `UserCreateInput`:

```graphql
input UserCreateInput {
email: String!
posts: PostCreateManyWithoutAuthorInput!
}
```
18 changes: 9 additions & 9 deletions experiments/prisma/generated/client/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9665,7 +9665,7 @@ export namespace Prisma {
uuid?: string
createdAt?: Date | string
updatedAt?: Date | string
published: boolean
published?: boolean
title: string
subtitle: string
content?: string | null
Expand All @@ -9679,7 +9679,7 @@ export namespace Prisma {
uuid?: string
createdAt?: Date | string
updatedAt?: Date | string
published: boolean
published?: boolean
title: string
subtitle: string
content?: string | null
Expand Down Expand Up @@ -9721,7 +9721,7 @@ export namespace Prisma {
uuid?: string
createdAt?: Date | string
updatedAt?: Date | string
published: boolean
published?: boolean
title: string
subtitle: string
content?: string | null
Expand Down Expand Up @@ -11908,7 +11908,7 @@ export namespace Prisma {
uuid?: string
createdAt?: Date | string
updatedAt?: Date | string
published: boolean
published?: boolean
title: string
subtitle: string
content?: string | null
Expand All @@ -11921,7 +11921,7 @@ export namespace Prisma {
uuid?: string
createdAt?: Date | string
updatedAt?: Date | string
published: boolean
published?: boolean
title: string
subtitle: string
content?: string | null
Expand All @@ -11944,7 +11944,7 @@ export namespace Prisma {
uuid?: string
createdAt?: Date | string
updatedAt?: Date | string
published: boolean
published?: boolean
title: string
subtitle: string
content?: string | null
Expand All @@ -11957,7 +11957,7 @@ export namespace Prisma {
uuid?: string
createdAt?: Date | string
updatedAt?: Date | string
published: boolean
published?: boolean
title: string
subtitle: string
content?: string | null
Expand Down Expand Up @@ -12369,7 +12369,7 @@ export namespace Prisma {
uuid?: string
createdAt?: Date | string
updatedAt?: Date | string
published: boolean
published?: boolean
title: string
subtitle: string
content?: string | null
Expand All @@ -12382,7 +12382,7 @@ export namespace Prisma {
uuid?: string
createdAt?: Date | string
updatedAt?: Date | string
published: boolean
published?: boolean
title: string
subtitle: string
content?: string | null
Expand Down
2 changes: 1 addition & 1 deletion experiments/prisma/generated/client/index.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion experiments/prisma/generated/client/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ model post {
uuid String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
published Boolean
/// @TypeGraphQL.omit(input: true)
published Boolean @default(false)
title String
/// @TypeGraphQL.omit(output: true)
subtitle String
Expand Down
24 changes: 13 additions & 11 deletions experiments/prisma/generated/type-graphql/dmmf.json
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,11 @@
"isId": false,
"isReadOnly": false,
"type": "Boolean",
"hasDefaultValue": false,
"hasDefaultValue": true,
"default": false,
"isGenerated": false,
"isUpdatedAt": false
"isUpdatedAt": false,
"documentation": "@TypeGraphQL.omit(input: true)"
},
{
"name": "title",
Expand Down Expand Up @@ -6903,7 +6905,7 @@
},
{
"name": "published",
"isRequired": true,
"isRequired": false,
"isNullable": false,
"inputTypes": [
{
Expand Down Expand Up @@ -7057,7 +7059,7 @@
},
{
"name": "published",
"isRequired": true,
"isRequired": false,
"isNullable": false,
"inputTypes": [
{
Expand Down Expand Up @@ -7633,7 +7635,7 @@
},
{
"name": "published",
"isRequired": true,
"isRequired": false,
"isNullable": false,
"inputTypes": [
{
Expand Down Expand Up @@ -26933,7 +26935,7 @@
},
{
"name": "published",
"isRequired": true,
"isRequired": false,
"isNullable": false,
"inputTypes": [
{
Expand Down Expand Up @@ -27074,7 +27076,7 @@
},
{
"name": "published",
"isRequired": true,
"isRequired": false,
"isNullable": false,
"inputTypes": [
{
Expand Down Expand Up @@ -27294,7 +27296,7 @@
},
{
"name": "published",
"isRequired": true,
"isRequired": false,
"isNullable": false,
"inputTypes": [
{
Expand Down Expand Up @@ -27435,7 +27437,7 @@
},
{
"name": "published",
"isRequired": true,
"isRequired": false,
"isNullable": false,
"inputTypes": [
{
Expand Down Expand Up @@ -31557,7 +31559,7 @@
},
{
"name": "published",
"isRequired": true,
"isRequired": false,
"isNullable": false,
"inputTypes": [
{
Expand Down Expand Up @@ -31702,7 +31704,7 @@
},
{
"name": "published",
"isRequired": true,
"isRequired": false,
"isNullable": false,
"inputTypes": [
{
Expand Down
24 changes: 13 additions & 11 deletions experiments/prisma/generated/type-graphql/prisma-client-dmmf.json
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,11 @@
"isId": false,
"isReadOnly": false,
"type": "Boolean",
"hasDefaultValue": false,
"hasDefaultValue": true,
"default": false,
"isGenerated": false,
"isUpdatedAt": false
"isUpdatedAt": false,
"documentation": "@TypeGraphQL.omit(input: true)"
},
{
"name": "title",
Expand Down Expand Up @@ -6903,7 +6905,7 @@
},
{
"name": "published",
"isRequired": true,
"isRequired": false,
"isNullable": false,
"inputTypes": [
{
Expand Down Expand Up @@ -7057,7 +7059,7 @@
},
{
"name": "published",
"isRequired": true,
"isRequired": false,
"isNullable": false,
"inputTypes": [
{
Expand Down Expand Up @@ -7633,7 +7635,7 @@
},
{
"name": "published",
"isRequired": true,
"isRequired": false,
"isNullable": false,
"inputTypes": [
{
Expand Down Expand Up @@ -26933,7 +26935,7 @@
},
{
"name": "published",
"isRequired": true,
"isRequired": false,
"isNullable": false,
"inputTypes": [
{
Expand Down Expand Up @@ -27074,7 +27076,7 @@
},
{
"name": "published",
"isRequired": true,
"isRequired": false,
"isNullable": false,
"inputTypes": [
{
Expand Down Expand Up @@ -27294,7 +27296,7 @@
},
{
"name": "published",
"isRequired": true,
"isRequired": false,
"isNullable": false,
"inputTypes": [
{
Expand Down Expand Up @@ -27435,7 +27437,7 @@
},
{
"name": "published",
"isRequired": true,
"isRequired": false,
"isNullable": false,
"inputTypes": [
{
Expand Down Expand Up @@ -31557,7 +31559,7 @@
},
{
"name": "published",
"isRequired": true,
"isRequired": false,
"isNullable": false,
"inputTypes": [
{
Expand Down Expand Up @@ -31702,7 +31704,7 @@
},
{
"name": "published",
"isRequired": true,
"isRequired": false,
"isNullable": false,
"inputTypes": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ export class PostCountOrderByAggregateInput {
})
updatedAt?: "asc" | "desc" | undefined;

@TypeGraphQL.Field(_type => SortOrder, {
nullable: true
})
published?: "asc" | "desc" | undefined;

@TypeGraphQL.Field(_type => SortOrder, {
nullable: true
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ export class PostCreateInput {
})
updatedAt?: Date | undefined;

@TypeGraphQL.Field(_type => Boolean, {
nullable: false
})
published!: boolean;

@TypeGraphQL.Field(_type => String, {
nullable: false
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ export class PostCreateManyAuthorInput {
})
updatedAt?: Date | undefined;

@TypeGraphQL.Field(_type => Boolean, {
nullable: false
})
published!: boolean;

@TypeGraphQL.Field(_type => String, {
nullable: false
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ export class PostCreateManyEditorInput {
})
updatedAt?: Date | undefined;

@TypeGraphQL.Field(_type => Boolean, {
nullable: false
})
published!: boolean;

@TypeGraphQL.Field(_type => String, {
nullable: false
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ export class PostCreateManyInput {
})
updatedAt?: Date | undefined;

@TypeGraphQL.Field(_type => Boolean, {
nullable: false
})
published!: boolean;

@TypeGraphQL.Field(_type => String, {
nullable: false
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ export class PostCreateWithoutAuthorInput {
})
updatedAt?: Date | undefined;

@TypeGraphQL.Field(_type => Boolean, {
nullable: false
})
published!: boolean;

@TypeGraphQL.Field(_type => String, {
nullable: false
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ export class PostCreateWithoutEditorInput {
})
updatedAt?: Date | undefined;

@TypeGraphQL.Field(_type => Boolean, {
nullable: false
})
published!: boolean;

@TypeGraphQL.Field(_type => String, {
nullable: false
})
Expand Down
Loading

0 comments on commit e7a1184

Please sign in to comment.