Keeping border when updating cell’s font in Google Sheet

I am having problems with the border of the cell after sending request to change the font of the cell.

Here is my code:

$sheetId = "mySheetId"
$spreadSheetId = "mySpreadSheetId"
$requests = [
               new Google_Service_Sheets_Request([
                                'repeatCell' => [
                                    'cell' => [
                                        'userEnteredFormat' => [
                                            "horizontalAlignment" => "CENTER",
                                            'textFormat' => [
                                                "foregroundColor" => [
                                                    "red" => 1
                                                ],
                                                "bold"=>true
                                            ]
                                        ]
                                    ],
                                    'range' => [
                                        'sheetId' => $sheetId,  
                                        'startRowIndex' => 11,
                                        'endRowIndex' => 13,
                                        'startColumnIndex' => 9,
                                        'endColumnIndex' => 10
                                    ],
                                    'fields' => 'userEnteredFormat'
                                ]
                            ])
                        ]; 
$batchUpdateRequest = new Google_Service_Sheets_BatchUpdateSpreadsheetRequest([
                            'requests' => $requests
                        ]);
$response = $serviceGoogleSheet->spreadsheets->batchUpdate($spreadSheetId,
                            $batchUpdateRequest);  

Here is how it is before the change

before

After change, the text is changed to what I want but some lines in the border disappeared

after

Is there a way to keep it as old or I will have to add some update border in my request to change it back ?

Answer

In your situation, I thought that when the the value of fields is modified, your issue might be able to be removed. So how about modifying your script as follows?

From:

'fields' => 'userEnteredFormat'

To:

'fields' => 'userEnteredFormat.horizontalAlignment,userEnteredFormat.textFormat'

and

'fields' => 'userEnteredFormat(horizontalAlignment,textFormat)'

Reference: