@@ -1247,16 +1247,23 @@ async def save(
12471247
12481248 if not isinstance (self ._schema , GenericSchemaAPI ):
12491249 if "CoreGroup" in self ._schema .inherit_from :
1250+ if self .id is None :
1251+ raise UninitializedError ("Cannot add related groups before the node has an ID" )
12501252 await self ._client .group_context .add_related_groups (
12511253 ids = [self .id ], update_group_context = update_group_context
12521254 )
12531255 else :
1256+ if self .id is None :
1257+ raise UninitializedError ("Cannot add related nodes before the node has an ID" )
12541258 await self ._client .group_context .add_related_nodes (
12551259 ids = [self .id ], update_group_context = update_group_context
12561260 )
12571261 else :
1258- await self ._client .group_context .add_related_nodes (ids = [self .id ], update_group_context = update_group_context )
1259-
1262+ if self .id is None :
1263+ raise UninitializedError ("Cannot add related nodes before the node has an ID" )
1264+ await self ._client .group_context .add_related_nodes (
1265+ ids = [self .id ], update_group_context = update_group_context
1266+ )
12601267 self ._client .store .set (node = self )
12611268
12621269 async def generate_query_data (
@@ -1441,7 +1448,7 @@ async def _process_mutation_result(
14411448 self , mutation_name : str , response : dict [str , Any ], timeout : int | None = None
14421449 ) -> None :
14431450 object_response : dict [str , Any ] = response [mutation_name ]["object" ]
1444- self .id = object_response ["id" ]
1451+ self .id = str ( object_response ["id" ])
14451452 self ._existing = True
14461453
14471454 for attr_name in self ._attributes :
@@ -1775,10 +1782,19 @@ def save(
17751782
17761783 if not isinstance (self ._schema , GenericSchemaAPI ):
17771784 if "CoreGroup" in self ._schema .inherit_from :
1778- self ._client .group_context .add_related_groups (ids = [self .id ], update_group_context = update_group_context )
1785+ if self .id is None :
1786+ raise UninitializedError ("Cannot add related nodes before the node has an ID" )
1787+ self ._client .group_context .add_related_nodes (
1788+ ids = [self .id ], update_group_context = update_group_context
1789+ )
1790+
17791791 else :
1792+ if self .id is None :
1793+ raise UninitializedError ("Cannot add related nodes before the node has an ID" )
17801794 self ._client .group_context .add_related_nodes (ids = [self .id ], update_group_context = update_group_context )
17811795 else :
1796+ if self .id is None :
1797+ raise UninitializedError ("Cannot add related nodes before the node has an ID" )
17821798 self ._client .group_context .add_related_nodes (ids = [self .id ], update_group_context = update_group_context )
17831799
17841800 self ._client .store .set (node = self )
@@ -1964,7 +1980,7 @@ def _process_mutation_result(
19641980 self , mutation_name : str , response : dict [str , Any ], timeout : int | None = None
19651981 ) -> None :
19661982 object_response : dict [str , Any ] = response [mutation_name ]["object" ]
1967- self .id = object_response ["id" ]
1983+ self .id = str ( object_response ["id" ])
19681984 self ._existing = True
19691985
19701986 for attr_name in self ._attributes :
0 commit comments