Kuali GraphQL Documentation

Guides

Update a document

Update the fields in a document.


Overview

Updating a document via code is a common operation that is relatively straightforward, but it is also pretty different because of Kuali's configurable forms. The fields in each form are completely different so you need to understand how to reference the unique id of each field you want to update.

Update a document

The previous article explains how to get the schema of a form. That schema includes the formKey of each field in the form.

For this example, let's assume that we have a form that has a field with a formKey of data.nYMA37CRlj and we want to update data in that field.

Note: You need the id of the specific document you want to update and you pass that as a variable. You can get that from the list of documents.

Query

      
        mutation ($id: ID!, $data: JSON!) {
  updateDocument(args: {id: $id, data: $data}) {
    id
    data
  }
}

      
    

Variables

      
{
  "id": "640266d76f0562f58f9197c6",
  "data": {
    "nYMA37CRlj": "History 201"
  }
}

      
    

Results

      
        {
          "data": {
            "updateDocument": {
              "id": "640266d76f0562f58f9197c6",
              "data": {
                "nYMA37CRlj": "History 201"
              }
            }
          }
        }