graph
bulk_insert
Bulk-load nodes and edges in chunks.
strata graph bulk-insertdb.graphs.bulk_insert(graph: 'str', *, nodes: 'Optional[list]' = None, edges: 'Optional[list]' = None, chunk_size: 'Optional[int]' = None) -> 'Any'wire graph_bulk_insert
Ingests a payload of nodes and edges in chunked commits: nodes first, then edges, so edges may reference nodes from the same payload. Node objects use the key `node_id`; edges use `src`, `edge_type`, `dst`, and optional `weight` (default 1.0) and `properties`. `chunk_size` bounds items per commit (default 512, clamped at 800). The acknowledgement reports inserted counts, the number of chunk commits, and the final chunk's commit receipt.
Each chunk is its own commit, so an interruption leaves the chunks that landed. An import that spans more than one commit sets a durable watermark on the graph with its first commit and clears it with its last: `graph meta` reports `import_pending: true` in between, and afterwards if the import was cut short. The watermark says a multi-commit import is in progress, not which payload: it is cleared by whichever `graph bulk_insert`'s last chunk lands next, whatever its chunk size, and ordinary writes leave it as it is. Every row is an upsert, so finishing an interrupted import is re-running its own payload; the graph stays readable and writable throughout.
Successful mutations return an acknowledgement of the outcome: for a state-changing write, the affected target with the mutation effect and commit facts; for mutations that produce a domain result (such as a branch or a promotion outcome), that result object.
To see the complete help for this command, run:
strata graph bulk-insert --helphelp(db.graphs.bulk_insert)
Example
Insert many nodes and edges in one commit.
strata graph create gcreated graph gstrata command run --command-json '{"edges":[{"dst":"b","edge_type":"knows","src":"a"}],"graph":"g","nodes":[{"node_id":"a","object_type":"person"},{"node_id":"b","object_type":"person"}],"type":"graph_bulk_insert"}'inserted 2 nodes, 1 edge into gstrata graph meta ggraph gnode_count 2edge_count 1created_version 3updated_version 5import_pending false
_ = db.graphs.create("g")_ = db.graphs.bulk_insert("g", nodes=[{"node_id": "a", "object_type": "person"}, {"node_id": "b", "object_type": "person"}], edges=[{"src": "a", "edge_type": "knows", "dst": "b"}])db.graphs.meta("g").node_count
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| graph | string | yes | Graph name. |
| branch | string or null | no | Target branch. Defaults to the executor handle branch. |
| chunk_size | integer or null | no | Optional items-per-commit chunk size. Defaults to 512; values above 800 clamp so one chunk fits one storage commit. |
| edges | array | no | Edges to upsert; endpoints must exist or arrive in `nodes`. |
| nodes | array | no | Nodes to upsert (committed before edges). |
| space | string or null | no | Target product space. Defaults to `"default"`. |
Returns
MutationAck
- dataobject
- typestring
Errors
Recover by code. Retry policy and commit outcome come from the shipped error registry.
| Code | Retry | Commit outcome |
|---|---|---|
| failed_precondition.engine.runtime_closed | never | not_started |
| not_found.engine.branch | never | not_applicable |
| invalid_argument.engine.product_space | never | not_started |
| invalid_argument.engine.graph_name | never | not_started |
| not_found.engine.graph | never | not_applicable |
| invalid_argument.engine.graph_node_id | never | not_started |
| invalid_argument.engine.graph_edge_type | never | not_started |
| invalid_argument.engine.graph_edge_weight | never | not_started |
| invalid_argument.engine.graph_edge_endpoint | never | not_started |
| invalid_argument.engine.graph_properties | never | not_started |
| invalid_argument.engine.graph_properties_too_large | never | not_started |
| failed_precondition.engine.graph_negative_weight | never | not_started |
| failed_precondition.engine.graph_ontology_edge_type | never | not_started |
| failed_precondition.engine.graph_ontology_node_type | never | not_started |