Skip to content

Commit d6ff625

Browse files
committed
chore: removed language specific doc from mutations
1 parent e0e6948 commit d6ff625

File tree

1 file changed

+0
-29
lines changed

1 file changed

+0
-29
lines changed

content/graphql/mutations.md

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -41,35 +41,6 @@ export class UpvotePostInput {
4141

4242
> info **Hint** The `@InputType()` decorator takes an options object as an argument, so you can, for example, specify the input type's description. Note that, due to TypeScript's metadata reflection system limitations, you must either use the `@Field` decorator to manually indicate a type, or use a [CLI plugin](/graphql/cli-plugin).
4343
44-
> info **Hint** When a field is nullable you need to type it verbosely in order to prevent any runtime issue:
45-
>
46-
> ```ts
47-
> @Field(() => String, {{ '{' }} nullable: true {{ '}' }}) title?: string | null;
48-
> ```
49-
>
50-
> This is particularly important when dealing with partial updates in your API, especially if the corresponding database field is non-nullable (let's assume `author.title` is a mandatory field in database).
51-
>
52-
> Problem: assume you want to allow users to perform partial updates on `author`'s info. So you define the `title` field in your `Input` object type:
53-
>
54-
> ```ts
55-
> @Field(() => String, {{ '{' }} nullable: true {{ '}' }}) title?: string;
56-
> ```
57-
>
58-
> Indicating that user can skip `title` entirely in an update mutation. However if a user sends `null` explicitly for `title` and you pass the DTO directly to your database, something like this:
59-
>
60-
> ```ts
61-
> prisma.author.update({{ '{' }}
62-
> where: {{ '{' }}
63-
> id: author.id
64-
> {{ '}' }},
65-
> data: dto
66-
> {{ '}' }})
67-
> ```
68-
>
69-
> Then your database will throw an error because `null` is not assignable to `title` which is non-nullable.
70-
>
71-
> Solution: To prevent this from happening you can be more specific when you're defining `title`'s type: `@Field(() => String, {{ '{' }} nullable: true {{ '}' }}) title?: string | null;`. Now when you're passing your DTO directly to the underlying ORM TS complain that `null` is not assignable to `string`.
72-
7344
We can then use this type in the resolver class:
7445

7546
```typescript

0 commit comments

Comments
 (0)