Expose work item custom field values in GraphQL

What does this MR do and why?

Returns the custom fields available to a work item and their corresponding values

References

Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

  1. Enable the custom_fields_feature feature flag

  2. Setup some custom fields in http://localhost:3000/groups/flightjs/-/settings/issues

  3. There's currently no way to map custom fields to work item types in the UI so you can do it in the console:

    Issuables::CustomField.find(xx).work_item_type_ids = [1] # to enable a custom field on issue types
  4. You can also set custom field values from the console since there's no UI for this yet:

    WorkItems::TextFieldValue.create!(work_item_id: xx, custom_field_id: yy, value: 'some text')
    WorkItems::NumberFieldValue.create!(work_item_id: xx, custom_field_id: yy, value: 100)
    WorkItems::SelectFieldValue.create!(work_item_id: xx, custom_field_id: yy, custom_field_select_option_id: zz) # create multiple entries for multi-select
  5. Sample query for custom fields widget of a work item

     query {
       namespace(fullPath: "flightjs/flight") {
         workItem(iid: "81") {
           id
           title
           workItemType {
             id
             name
           }
           widgets {
             type
             ... on WorkItemWidgetCustomFields {
               customFieldValues {
                 customField {
                   id
                   name
                 }
                 ... on WorkItemTextFieldValue {
                   value
                 }
                 ... on WorkItemNumberFieldValue {
                   value
                 }
                 ... on WorkItemSelectFieldValue {
                   selectedOptions {
                     id
                     value
                   }
                 }
               }
             }
           }
         }
       }
     }
Edited by Heinrich Lee Yu

Merge request reports

Loading