Pass the variables from records.Update by bulkUpdate JS to GraphQL Query

Hi Retool Community,

I am trying to find my way around editing table in bulk but I'm stuck at sending the additionalScope variables to the updateCustomer query. Here is my code:


const toUpdate = Child_Table.recordUpdates

function toArray(obj){
  const array_obj = [];
  obj.forEach((item) => {
    var arr2 = {};
    for (var key in item) {
      if (null === item[key].name) item[key].name = " ";
      arr2[key] = item[key].name ? item[key].name : item[key];	
  return array_obj

const data = toArray(toUpdate)

return data

data.forEach((record) => {
    additionalScope: {
      uid: record.uid,
      firstname: record.firstname,
      middlename: record.middlename,
      lastname: record.lastname,
      dob: record.dob,
      eid: record.eid

I have created the above function because recordsUpdate will have objects for the updated records and a nested objects that I have to call to access it. The above function breaks the nested loop.

This query is triggered when the "Save Changes" Button is clicked. Additionally, when this query successfully runs, it triggers the updateCustomer GraphQL Query below:

updateCustomer GraphQL Query:

mutation($uid: String!, $firstname: String!,$middlename: String!, $lastname: String!,$phone: String!, $email: String!, $dob: String!,$eid: String!){
    uid: $uid,
    firstname: $firstname,
    middlename: $middlename,
    lastname: $lastname,
    phone: $phone,
    email: $email,
    dob: $dob,
    eid: $eid,

Running the bulkUpdateCustomer gives the following output:


However, updateCustomer query gets an error:

updateCustomer: Variable "$uid" of non-null type "String!" must not be null.

This is a variable to be able to reproduce my situation

var toUpdate = [{"uid":"b7ff18ba-86b3-4e39-8545-69e34772ed23","firstname":"Fready","middlename":{"name":null},"lastname":{"name":"rodriguez"},"phone":{"name":"1-683-456-3221 x7259"},"email":{"name":"m"},"dob":{"name":"2021-09-12T05:21:21.316Z"},"eid":{"name":"82312855"},"car":{"name":"aston martin"}},{"uid":"6552d9e7-d514-4fb5-8250-4eded7049c60","firstname":"martinas","middlename":{"name":" "},"lastname":{"name":"steuber"},"phone":{"name":"344.389.3397 x36695"},"email":{"name":null},"dob":{"name":"2021-10-10T20:36:50.866Z"},"eid":{"name":"117723513"},"car":{"name":"ford"}},{"uid":"96d1c861-df13-494d-b7da-cbd394910415","firstname":"fredys","middlename":{"name":"c"},"lastname":{"name":"rodriguez"},"phone":{"name":"1-683-456-3221 x7259"},"email":{"name":" "},"dob":{"name":"2021-09-12T05:21:21.316Z"},"eid":{"name":"82312855"},"car":{"name":"smart"}}]


Hey there! It looks like you are returning your data before the trigger in bulkUpdateCustomer.js.

The additional scope variables passed won't be defined unless this query is triggered and the additional scope object is passed. How are you triggering this query?\

1 Like


You're absolutely correct. I should delete that line. I added it to test my results but forgot to remove it afterwards. I treated as part of my code and forgot to delete it.

It is working now.

Thank you very much. Been stuck for hours on this.

1 Like