Skip to content

Commit a3b4055

Browse files
Update mapped-types.md
1 parent fc03ab0 commit a3b4055

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

content/graphql/mapped-types.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ 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 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:
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()
@@ -132,13 +132,6 @@ export class UpdateUserInput extends IntersectionType(CreateUserInput, Additiona
132132

133133
> info **Hint** The `IntersectionType()` function is imported from the `@nestjs/graphql` package.
134134
135-
The `IntersectionType()` function takes an optional third argument that is a reference to the decorator factory of the type being extended. If you don't pass a type as the third argument, it will use the first argument's decorator factory type. If you want to extend a class decorated with `@ObjectType`, pass `ObjectType` as the third argument. For example:
136-
137-
```typescript
138-
@InputType()
139-
export class UpdateUserInput extends IntersectionType(CreateUserInput, AdditionalUserInfo, ObjectType) {}
140-
```
141-
142135
#### Composition
143136

144137
The type mapping utility functions are composable. For example, the following will produce a type (class) that has all of the properties of the `CreateUserInput` type except for `email`, and those properties will be set to optional:

0 commit comments

Comments
 (0)