paleobot / pbot-api

MIT License
2 stars 0 forks source link

Handle relationship properties #16

Closed NoisyFlowers closed 2 years ago

NoisyFlowers commented 2 years ago

Oh FFS, it seems I forgot to handle relationship properties in the Create and Update resolvers.

I'll have to fix this before I can move ahead with author/reference/state ordering.

NoisyFlowers commented 2 years ago

This is in f7b611f2c3e6cfe1a4038fca598fd72d0f1a2e21, de3db77904dd77cf3af364ce81fb3caa0661fec0, 60ab407569401730f727eda7c66f4d1f631290af, 0b37334157b8e498a27645011c23e00961e73e05, fbc891d1e447f852c44f4c151518d4436325411b, 4254cbe0d5dcd20e487d09a9afcf62d13ae5cb55, 926bd0354ba426687dc68b793c7958a894dbea5f

NoisyFlowers commented 2 years ago

A note on an important change required by this solution:

Previously, we stored old relationships in the EDIT ENTERED_BY as an array of the pbotIDs on the other end. This did not capture the relationship properties. To do that in cypher, we now use collect(apoc.convert.toJson(the relationship variable)). This yields arrays in the EDIT ENTERED_BY that look like this:

["{"id":"2422","type":"relationship","label":"CITED_BY","start":{"id":"667","type":"node","labels":["Reference"],"properties":{"pbotID":"0eb76b08-2dbb-4a78-86ef-645ceda2010e","year":"2022","publisher":"me","title":"Ref-ddm-03-22b"}},"end":{"id":"701","type":"node","labels":["Schema"],"properties":{"pbotID":"4cc45f69-529f-4d7b-8c90-f98fb37a176a","year":"2021","title":"Sch-ddm-04-21c"}},"properties":{"order":"2"}}", "{"id":"2419","type":"relationship","label":"CITED_BY","start":{"id":"653","type":"node","labels":["Reference"],"properties":{"pbotID":"0809c491-9c9f-4493-8970-4a8fba25c6db","year":"2022","publisher":"me","title":"Ref-ddm-03-11a"}},"end":{"id":"701","type":"node","labels":["Schema"],"properties":{"pbotID":"4cc45f69-529f-4d7b-8c90-f98fb37a176a","year":"2021","title":"Sch-ddm-04-21c"}},"properties":{"order":"1"}}"]

Each relationship is represented here as


{
id: _internal neo4j id_
type: "relationship"
label: _our name for the relationship_
start: _everything about the start node, including its pbotID_
end: _everything about the end node, including its pbotID_
properties: _the relationship properties_
}

It's a bit messier than a simple array of pbotIDs, but any info we might need in the future is all there.