def test_09_custom_query(neo4j_graph_store: Neo4jGraphStore):
    """
    Test running a direct custom Cypher query via .query().
    """
    store = neo4j_graph_store
    store.upsert_triplet("TestS", "TEST_REL", "TestO")

    # Custom query to find all nodes that have an outgoing relationship
    custom_cypher = """
    MATCH (n)-[r]->(m)
    RETURN n.id AS subject, type(r) AS relation, m.id AS object
    """
    results = store.query(custom_cypher)
    assert len(results) >= 1
    # Expect at least the one we inserted
    expected = {"subject": "TestS", "relation": "TEST_REL", "object": "TestO"}
    assert any(
        row["subject"] == expected["subject"]
        and row["relation"] == expected["relation"]
        and row["object"] == expected["object"]
        for row in results
    ), "Custom query did not return the inserted relationship."

    Test running a direct custom Cypher query via .query().
    
llama-index-integrations/graph_stores/llama-index-graph-stores-neo4j/tests/test_graph_stores_neo4j.py