Skip to content

Commit 9a63fc4

Browse files
authored
fix: failed pipeline
1 parent 75c3e0e commit 9a63fc4

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

content/graphql/resolvers-map.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,7 @@ For example:
7878
title: string;
7979
```
8080

81-
> info **Hint** When a field is nullable you need to type it verbosely in order to prevent any runtime issue: `@Field(() => String, {nullable: true}) title?: string | null;`. This particularly important when dealing with parcial updates in your API, especially if the corresponding database field is non-nullable (e.g. `author.title`).
82-
>
83-
> **Problem**: assume the `title` field is defined like this: `@Field(() => String, { nullable: true }) title?: string;`, 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: `prisma.author.update({ where: { id: author.id }, data: dto })` your database will throw an error because `null` is not assignable to `title` which is non-nullable.
84-
>
85-
> **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`.
81+
> info **Hint** When a field is nullable you need to type it verbosely in order to prevent any runtime issue: `@Field(() => String, {nullable: true}) title?: string | null;`. This particularly important when dealing with parcial updates in your API, especially if the corresponding database field is non-nullable (e.g. `author.title`). **Problem**: assume the `title` field is defined like this: `@Field(() => String, { nullable: true }) title?: string;`, 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: `prisma.author.update({ where: { id: author.id }, data: dto })` your database will throw an error because `null` is not assignable to `title` which is non-nullable. **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`.
8682

8783
> info **Hint** You can also add a description to, or deprecate, the whole object type: `@ObjectType({{ '{' }} description: 'Author model' {{ '}' }})`.
8884

0 commit comments

Comments
 (0)