ent
ent copied to clipboard
UUIDListType fields codegen with errors in the Builder
A field defined as :
horseIDs: UUIDListType({
nullable: true,
fieldEdge: {
schema: 'Horse',
inverseEdge: {
name: 'competitionEntries',
},
},
}),
generates the following code block in getEditedFields
:
addField('horseIDs', input.horseIds);
if (input.horseIds !== undefined) {
if (input.horseIds) {
this.orchestrator.addInboundEdge(
input.horseIds, // Error here
EdgeType.HorseToCompetitionEntries,
NodeType.Horse,
);
}
if (
this.existingEnt &&
this.existingEnt.horseIds &&
this.existingEnt.horseIds !== input.horseIds
) {
this.orchestrator.removeInboundEdge(
this.existingEnt.horseIds, // Error here
EdgeType.HorseToCompetitionEntries,
);
}
}
There error is Argument of type 'ID[]' is not assignable to parameter of type 'ID'
. Not sure if it matters, but for me the field is defined on a pattern.
The should probably be generated as:
addField('horseIDs', input.horseIds);
if (input.horseIds) {
input.horseIds.forEach((horseId) =>
this.orchestrator.addInboundEdge(
horseId,
EdgeType.HorseToCompetitionEntries,
NodeType.Horse,
),
);
}
if (this.existingEnt && this.existingEnt.horseIds) {
this.existingEnt.horseIds.forEach((horseId) => {
if (!input.horseIds?.includes(horseId)) {
this.orchestrator.removeInboundEdge(
horseId,
EdgeType.HorseToCompetitionEntries,
);
}
});
}
hmm, i think UUIDlistType with inverseEdge hasn't worked in the past. is this a new field? or did this break with v0.2?
This is a new field. I ended up going a different direction anyways, so I'm not blocked on this, but it's still a valid bug.
Everything else seemed to work except that builder setting edges.