opsmill / infrahub

Infrahub - A new approach to Infrastructure Management
https://opsmill.com/
GNU Affero General Public License v3.0
208 stars 17 forks source link

feature: Add ability to update enum choices with a mutation #1555

Open ogenstad opened 11 months ago

ogenstad commented 11 months ago

Component

API Server / GraphQL

Describe the Feature Request

In #1531 we added the ability to add or remove enum choices on the attributes of a model with the SchemaEnumAdd and SchemaEnumRemove mutations. We also want a SchemaEnumUpdate mutation. It would allow end users to rename an enum choice. The simple approach would be to have a mutation that takes the old name and the new name and just renames the mutation. A problem with this is that the enum value is stored as a string for each object within the database.

Because of this just renaming the value within the database would require us to update all existing objects that was using the renamed enum choice. Aside from not being efficient it would lead to a potential huge diff when doing a proposed change.

A way around this would be to instead store the enum choices as a uuid in the database and convert the choice value into the name of the choice during serialisation. This is similar to how the Dropdown type shows color and description (the dropdown type should also store values as a uuid for the same reason).

Describe the Use Case

No response

Additional Information

No response

BeArchiTek commented 2 months ago

It seems possible for some months. Example :

mutation AddEnumChoice{
  SchemaEnumAdd(
    data: {
      kind: "InfraLayer2Interface"
      enum: "new-choice"
      attribute: "layer2"
    }
  ) {
    ok
  }
}

Will close this issue.

ogenstad commented 2 months ago

Hey, I'm reopening this. The issue is around updating existing choices i.e. renaming a choice. The mutations we have are around adding new choices or deleting unused ones.