Pick<IRoom, 'id'> removes every property from IRoom type except the 'id'.
Others fields are not used, so they are irrelevant to relationships and omitted. This matches the backend with DTO behavior passing only the id and the label field.
If you customized the ui with the code field, just customize the type by adding code to the Pick fields like:
export interface IHouse {
id: number;
creationDate?: dayjs.Dayjs | null;
room?: Pick<IRoom, 'id', 'code'> | null;
}
Or remove the Pick:
export interface IHouse {
id: number;
creationDate?: dayjs.Dayjs | null;
room?: IRoom | null;
}
Missing label field
The example jdl is:
entity Room {
code String
}
entity House {
creationDate Date
}
relationship ManyToOne {
House to Room
}
Adding a label to the relationship will generate like you want:
relationship ManyToOne {
House{room(code)} to Room
}
Result:
export interface IHouse {
id: number;
creationDate?: dayjs.Dayjs | null;
room?: Pick<IRoom, 'id', 'code'> | null;
}
Rest api without DTO
Given the jdl:
entity Room {
code String
}
entity House {
creationDate Date
}
relationship ManyToOne {
House{room} Room{house}
}
Serializing the an entity would generate a circular exception due to the bi-directional relationship.
To avoid the circular exception, the backend is generated ignoring relationships like:
class House {
JsonIgnoreProperties({'house', ...others relationships})
Room room;
}
In typescript:
type House {
room?: Omit<Room, 'house', ...others relationships>
}
Only the label field is relevant to the generated ui, we are using the Pick approach to keep templates simpler.
This can be easily customized using local blueprint.