Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UUIDListType fields codegen with errors in the Builder #1793

Open
Swahvay opened this issue Mar 5, 2024 · 4 comments
Open

UUIDListType fields codegen with errors in the Builder #1793

Swahvay opened this issue Mar 5, 2024 · 4 comments

Comments

@Swahvay
Copy link
Contributor

Swahvay commented Mar 5, 2024

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.

@Swahvay
Copy link
Contributor Author

Swahvay commented Mar 5, 2024

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,
      );
    }
  });
}

@lolopinto
Copy link
Owner

hmm, i think UUIDlistType with inverseEdge hasn't worked in the past. is this a new field? or did this break with v0.2?

@Swahvay
Copy link
Contributor Author

Swahvay commented Mar 5, 2024

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.

@Swahvay
Copy link
Contributor Author

Swahvay commented Mar 5, 2024

Everything else seemed to work except that builder setting edges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants