# patchWorkflowGraph

Edit a workflow version's graph by sending ONLY THE CHANGE (updateWorkflowGraph writes a whole new graph). Ids come from getWorkflowVersionGraph and CHANGE ON EVERY SAVE: patch again from the response's `graph`. `graphPatch`: ops applied in order, all or nothing. Ops: {op:"updateNode", id, config?, edits?} | {op:"addNode", node:{type, config}, after?: nodeId, onEdge?: edgeId} | {op:"removeNode", id, keepChild?} | {op:"addEdge", edge:{parentNodeId, childNodeId, config?}} | {op:"updateEdge", id, parentNodeId?, childNodeId?, config?} | {op:"removeEdge", id} | {op:"updateConfig", config} (graph.config) | {op:"addTrigger", trigger:{config}} | {op:"updateTrigger", id, config} | {op:"removeTrigger", id}. A `config` is a JSON merge patch: objects merge, null deletes a key, other values (arrays too) replace; {op:"updateNode", id, config:{seconds:86400}} makes a wait one day. `edits`: [{field:"textBody", find, replace}], each find exactly once in that text. `after` inserts after a step with one path out, `onEdge` on a branch edge; with neither the step is unconnected. A new edge out of a condition sets its config (`eval`/`path`). removeNode rejoins the flow; a condition needs `keepChild` (its other paths go). New step types: updateWorkflowGraph's NODE VOCABULARY. Saves like updateWorkflowGraph (same refusals, flags, draftValidation); a no-op patch is refused.

- Call: `POST https://server.goliathdata.com/api/v1/call` with `{ "operationId": "patchWorkflowGraph", "variables": {...} }`
- Scope: `WRITE`
- Type: mutation
- Idempotency: honors `Idempotency-Key` (24 h)
- Rate-limited: no

## Variables

- `workflowAutomationId`: `ID!` (required)
- `graphPatch`: `JSON!` (required)
- `expectedUpdatedAt`: `DateTime`
- `acknowledgeGraphWeakening`: `Boolean`

## Response (data, an example)

```json
{
  "workflowAutomationsMutation": {
    "updateWorkflowAutomationGraph": {
      "id": "<ID>",
      "workflowGroupId": "<ID>",
      "status": "DRAFT",
      "stepKinds": [
        "…"
      ],
      "updatedAt": "2026-01-01T00:00:00.000Z",
      "graph": "…",
      "workflowGroup": {
        "id": "<ID>",
        "draftValidation": {
          "isValid": true,
          "errors": [
            "…"
          ]
        }
      }
    }
  }
}
```

## Example

```bash
curl https://server.goliathdata.com/api/v1/call \
  -H "Authorization: Bearer $GOLIATH_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "operationId": "patchWorkflowGraph",
    "variables": {
      "workflowAutomationId": "<workflowAutomationId>",
      "graphPatch": "<JSON>"
    }
  }'
```
