Skip to Content
Stoatly Docs
Object types

Convert an enum to an object type

An enum can only hold a label. When each choice needs data of its own, convert it into an object type. Every value becomes a record, and every field that used the enum becomes a reference to that type. You'll need to be an admin or a schema designer.

A Rarity enum with Common, Rare and Epic becomes a Rarity object type with three records. You can then add a colour field and a drop rate to it.

Convert an enum

Open the enum

On the object type's Enums tab, open the enum.

Choose Convert to object

Open Enum actions and choose Convert to object….

Name the new object

Enter a New object name. It starts as the enum's name.

Review the preview

Stoatly shows what will happen before anything changes. See below.

Convert

Choose Convert. Stoatly opens the new object type.

What the preview shows

  • Records. One record is created per value.
  • Fields that become references. Each field that used the enum, the type it's on, and how many records hold a value in it. List fields stay lists.
  • Obsolete values. Values that were deprecated can be kept as obsolete records. Tick each one you want to keep.
  • Warnings. If records hold a value that won't be kept, they end up with no value, and Stoatly counts them. Reference fields have no default, so a default set on a converted field is cleared.

Some conversions are blocked. The reason appears in red and Convert stays disabled.

The Convert to an object dialog, previewing the records and fields, with a red reason that blocks the conversion.

Undo a conversion

Until you send your changes, the new object type shows "Converted from the enum" with a Discard conversion button. After the pull request merges, you can't revert it from here.

Next steps

Add fields to the new type, then send your changes.

On this page