aws / graph-explorer

React-based web application that enables users to visualize both property graph and RDF data and explore connections between data without having to write graph queries.
https://github.com/aws/graph-explorer
Apache License 2.0
299 stars 46 forks source link

Remove extraneous openCypher fetch #431

Closed kmcginnes closed 4 weeks ago

kmcginnes commented 4 weeks ago

Description

When expanding a node in openCypher Graph Explorer was executing two queries to the database.

The first would get all the node and edge neighbors to the expanded node that match the filter criteria using the query below.

MATCH (v)-[e]-(tgt:airport) 
WHERE ID(v) = "247" 
WITH 
    collect(DISTINCT tgt)[..12] AS vObjects, 
    collect({edge: e, sourceType: labels(v), targetType: labels(tgt)})[..12] AS eObjects 
RETURN 
    vObjects, eObjects

Then it would extract only the edge IDs from the results of the query above. It would send those edge IDs to another query that uses the exact same filter logic, but adds a new filter for those edge IDs specifically.

MATCH (v)-[e]-(tgt:airport) 
WHERE 
    ID(v) = "247" AND 
    ID(e) IN [
        "25753",
        "9253",
        "9700",
        "10000",
        "17120",
        "17542",
        "19868",
        "20428",
        "33362",
        "24309",
        "25618",
        "25610"
    ] 
WITH 
    collect(DISTINCT tgt)[..12] AS vObjects, 
    collect({edge: e, sourceType: labels(v), targetType: labels(tgt)})[..12] AS eObjects 
RETURN 
    vObjects, eObjects

It then uses the results from the second query to render the nodes.

I can not figure out why the two queries are necessary. The return the exact same information. Except the second query is way more likely to fail due to large ID(e) IN [...] filters.

So I removed the second edge filtered query. Graph Explorer seems to work much better now and is less likely to fail.

Validation

Related Issues

Check List