I'm working with the data structure Player
:
type Player = {
id: Scalars['ID'];
name: Scalars["String"];
age: Scalars["Int"];
description?: Maybe<Scalars["String"]>;
__typename?: "Player";
// ... and many other fields ...
};
My task is to insert a new Player
into an existing array:
let players: Player[] = [];
players = [...players, createNewPlayer()]
function createNewPlayer() {
return {
id: generateNewID(),
name: undefined,
age: undefined,
description: undefined,
// ... and so on with many other fields ...
}
}
However, I'm only interested in setting the newID()
for the new Player. The rest of the fields are irrelevant in this scenario.
Is there a way to avoid including all the undefined
fields in createNewPlayer()
?