Metadata-Version: 2.1
Name: cypher-subgraph
Version: 0.1.1
Summary: A python library and CLI tool that rewrites and generates cypher queries for supporting sub-graph.
Home-page: https://github.com/AlirezaRoshanzamir/cypher-subgraph/tree/main/src/cypher_subgraph
Author: Alireza Roshanzamir
Author-email: a.roshanzamir1996@gmail.com
License: MIT License
        
        Copyright (c) 2022 AlirezaRoshanzamir
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Platform: UNKNOWN
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE

# cypher-subgraph
A python library and CLI tool that rewrites and generates cypher queries for supporting subgraph.

# Installation
````
pip install cypher-subgraph
````

# CLI
````
Usage: cypher-subgraph [OPTIONS] COMMAND [ARGS]...

  Rewrite or generate query for supporting sub-graph feature.

Options:
  --help  Show this message and exit.

Commands:
  add-to       Rewrite the query read from standard input that the query
               returned values become the member of the specified "subgraph"
               argument.
  delete       Generate a query for deleting specfied "subgraph" argument.
  rewrite-for  Rewrite the query read from standard input that the query is
               executed only in the specified "subgraph" argument.
````

# Examples
There is no known limitation on the reading queries. All the commands work well
with Cypher **nodes**, **edges**, and **paths**.

Currently, running commands on multiple subgraphs at the same time is not
supported. You should pass the previous rewritten query again to rewrite
queries for multiple subgraphs.

## add-to

Rewriting the query which the returned values becomes the member of "sg"
subgraph:
```
cypher-subgraph add-to sg << EOF
MATCH (v) RETURN v
EOF
```

returns:
```
MATCH (v) WITH v
SET v.__subgraph_sg = true
```

## rewrite-for

Rewrite the query which it only will be executed in the "sg" subgraph:

```
cypher-subgraph rewrite-for sg << EOF
MATCH (v) RETURN v
EOF
```

returns:
```
MATCH (v { __subgraph_sg: true }) RETURN v
```

## delete
Delete subgraph "sg" meta-data:
```
cypher-subgraph delete sg
```

returns:
```
MATCH (v) OPTIONAL MATCH (v)-[e]-() REMOVE v.__subgraph_sg REMOVE e.__subgraph_sg
```

# Implementation

The tool mimics the subgraph feature using the addition property for the nodes
and edges. For each node and edge which is inside the "x" subgraph, the
property "__subgraph_x" will be set true.


