Performance: Object types and input types
MEDIUM IMPACT
This concept affects server response time and client rendering speed by influencing how data is validated and transformed before processing.
import { ObjectType, Field, InputType } from '@nestjs/graphql'; @ObjectType() export class User { @Field() name: string; @Field() age: number; // password field omitted from output type } @InputType() export class CreateUserInput { @Field() name: string; @Field() age: number; @Field() password: string; // only in input type }
import { ObjectType, Field, InputType } from '@nestjs/graphql'; @ObjectType() export class User { @Field() name: string; @Field() age: number; @Field() password: string; // included in output type } @InputType() export class CreateUserInput { @Field() name: string; @Field() age: number; @Field() password: string; }
| Pattern | Payload Size | Network Transfer | Client Parsing | Verdict |
|---|---|---|---|---|
| Including sensitive fields in output types | Large | Slower | More CPU | [X] Bad |
| Separating input and output types properly | Small | Faster | Less CPU | [OK] Good |