Manage Fields

Fields can be added or removed from objects using the editFieldConfiguration. Many fields can be edited at once, but only on a single object at a time.

If attempting to create a new field that already exists in the active version an error will be thrown, however creating a field that already exists within the same version will replace the field. You can use this to change details (i.e the field type) in the version you are editing.

The object type for edits fields must be supplied to the object_class argument.

The fields for editing a field are:

  • name: The name of the field (Required)
  • type: The scalar type of the field. Defaults to STRING.
  • is_translatable: Boolean whether the field allows for different languages (Required)
  • operation: Option to create or delete the field (Required)
  • required: Boolean whether the field is required at create input
  • enum_name: When creating an enum type, you must specify an existing enum name

The following field types can be created:

  • STRING
  • INTEGER
  • BOOLEAN
  • FLOAT
  • ENUM
  • DATETIME
  • DATE
  • EMAIL
  • IP_ADDRESS
  • JSON
  • PHONE
  • TIME
  • TIMESTAMP
  • URL

Using the ENUM type

When using the ENUM type the field enum_name must also be supplied. The value of enum_name must be an enum that already exists on your schema or in the draft you are working on. See Manage Enums for working with enums.

ENUM type are never translatable.

mutation MyMutation {
  editFieldConfiguration(
    object_class: Episode, 
    version: 2
    fields: [
      {
        name: "my_new_enum_field",
        enum_name: "ExistingEnum",
        type: ENUM, 
        operation: CREATE
      }
    ]
  ) {
    version
    messages
  }
}

Create multiple new fields

This example shows creating fields of many different types

mutation MyMutation {
  editFieldConfiguration(
    object_class: Episode, 
    version: 2
    fields: [
      {
        name: "new_required_translatable_string",
        type: STRING, 
        operation: CREATE, 
        is_translatable: true,
        required: true
      },
      {
        name: "new_non_required_translatable_string",
        type: STRING, 
        operation: CREATE, 
        is_translatable: true,
        required: false
      },
      {
        name: "new_required_integer",
        type: INTEGER, 
        operation: CREATE, 
        is_translatable: false,
        required: true
      },
      {
        name: "new_non_required_boolean",
        type: BOOLEAN, 
        operation: CREATE, 
        is_translatable: false,
        required: false
      }
    ], 
  ) {
    version
    messages
  }
}