Skip to content

Commit 0d63101

Browse files
Merge pull request #1167 from longngn/patch-1
Update graphql/mapped-types.md
2 parents 5292d37 + c0c8815 commit 0d63101

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

content/graphql/mapped-types.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ export class UpdateUserInput extends PartialType(CreateUserInput) {}
3535

3636
> info **Hint** The `PartialType()` function is imported from the `@nestjs/graphql` package.
3737
38-
The `PartialType()` function takes an optional second argument that is a reference to the decorator factory of the type being extended. In the example above, we are extending `CreateUserInput` which is annotated with the `@InputType()` decorator. We didn't need to pass `InputType` as the second argument since it's the default value. If you want to extend a class decorated with `@ObjectType`, pass `ObjectType` as the second argument. For example:
38+
The `PartialType()` function takes an optional second argument that is a reference to a decorator factory. This argument can be used to change the decorator function applied to the resulting (*child*) class. If not specified, the child class effectively uses the same decorator as the *parent* class (the class referenced in the first argument). In the example above, we are extending `CreateUserInput` which is annotated with the `@InputType()` decorator. Since we want `UpdateUserInput` to also be treated as if it were decorated with `@InputType()`, we didn't need to pass `InputType` as the second argument. If the parent and child types are different, (e.g., the parent is decorated with `@ObjectType`), we would pass `InputType` as the second argument. For example:
3939

4040
```typescript
4141
@InputType()
42-
export class UpdateUserInput extends PartialType(User, ObjectType) {}
42+
export class UpdateUserInput extends PartialType(User, InputType) {}
4343
```
4444

4545
#### Pick

0 commit comments

Comments
 (0)