Skip to content

Commit

Permalink
Support testkit serialization of relationships and paths
Browse files Browse the repository at this point in the history
  • Loading branch information
fbiville committed Aug 26, 2021
1 parent 6097f71 commit 6b1b8a0
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion testkit-backend/2cypher.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,38 @@ func nativeToCypher(v interface{}) map[string]interface{} {
return valueResponse("CypherMap", values)
case neo4j.Node:
return map[string]interface{}{
"name": "Node", "data": map[string]interface{}{
"name": "Node",
"data": map[string]interface{}{
"id": nativeToCypher(x.Id),
"labels": nativeToCypher(x.Labels),
"props": nativeToCypher(x.Props),
}}
case neo4j.Relationship:
return map[string]interface{}{
"name": "Relationship",
"data": map[string]interface{}{
"id": nativeToCypher(x.Id),
"startNodeId": nativeToCypher(x.StartId),
"endNodeId": nativeToCypher(x.EndId),
"type": nativeToCypher(x.Type),
"props": nativeToCypher(x.Props),
}}
case neo4j.Path:
nodes := make([]interface{}, len(x.Nodes))
for i := range x.Nodes {
nodes[i] = x.Nodes[i]
}
rels := make([]interface{}, len(x.Relationships))
for i := range x.Relationships {
rels[i] = x.Relationships[i]
}
return map[string]interface{}{
"name": "Path",
"data": map[string]interface{}{
"nodes": nativeToCypher(nodes),
"relationships": nativeToCypher(rels),
},
}
}
panic(fmt.Sprintf("Don't know how to patch %T", v))
}
Expand Down

0 comments on commit 6b1b8a0

Please sign in to comment.