88
99
1010class InfrahubObjectFileData (BaseModel ):
11- kind : Optional [ str ] = None
11+ kind : str
1212 data : list [dict [str , Any ]] = Field (default_factory = list )
1313
1414 @classmethod
@@ -35,21 +35,21 @@ async def create_node(
3535 remaining_rels = []
3636 for key , value in data .items ():
3737 if key in schema .attribute_names :
38- # NOTE we could validate the format of the data but the API will do it as well
3938 clean_data [key ] = value
4039
4140 if key in schema .relationship_names :
4241 rel_schema = schema .get_relationship (name = key )
4342
44- if not isinstance (value , dict ) and "data" in value :
45- raise ValueError (f"relationship { key } must be a dict with 'data'" )
43+ if isinstance (value , dict ) and "data" not in value :
44+ raise ValueError (f"Relationship { key } must be a dict with 'data'" )
4645
47- if rel_schema .cardinality == "one" or rel_schema .optional is False :
48- raise ValueError (
49- "Not supported yet, we need to have a way to define connect object before they exist"
50- )
51- # clean_data[key] = value[data]
52- remaining_rels .append (key )
46+ # This is a simple implementation for now, need to revisit once we have the integration tests
47+ if isinstance (value , (list )):
48+ clean_data [key ] = value
49+ elif rel_schema .cardinality == "one" and isinstance (value , str ):
50+ clean_data [key ] = [value ]
51+ else :
52+ remaining_rels .append (key )
5353
5454 if context :
5555 clean_context = {
0 commit comments