lolopinto / ent

MIT License
51 stars 6 forks source link

Edge Actions ignore actionOnlyFields #1803

Closed Swahvay closed 5 months ago

Swahvay commented 5 months ago

I have an edge defined as:

{
  name: 'someEdge',
  schemaName: 'User',
  edgeActions: [
    {
      operation: ActionOperation.AddEdge,
      actionName: 'AddSomeEdge',
      actionOnlyFields: [
        {
          name: 'verificationNumber',
          type: 'Int',
        },
      ],
    },
  ],
},

But the AddSomeEdgeAction and its corresponding base never generate the input type with verificationNumber. I want to use it to add a trigger that calls builder.storeData so it can store it on the edge row.

Swahvay commented 3 months ago

So, I figured out what the problem is here. The generated action now has a 3rd parameter, which is the actionOnlyFields, but that changes this from only allowing one edge to be created per action. Previously I could do this in my trigger:

const action = AddSomeEdgeToEntAction.create(
  viewer,
  ent,
);
edgeIDsToAdd.forEach(id => action.addSomeEdgeToEntID(id));
return action.changeset();

But I think now I have to do:

return Promise.all(edgeIDsToAdd.map(id => (
  AddSomeEdgeToEntAction.create(
    viewer,
    ent,
    { dataToSave: id + 'foo' },
  )
    .addSomeEdgeToEntID(id)
    .changeset(),
));

Is that right?