Nodes { @UserFunction("apoc.rel.id") @Description("returns id for (virtual) relationships") public Long relId(@Name("rel") Relationship rel) { return (rel == null) ? null : rel.getId(); }  @Procedure(mode = Mode.WRITE) @Description("apoc.nodes.link([nodes],'REL_TYPE') - creates a linked list of nodes from first to last") void link(@Name("nodes") List<Node> nodes, @Name("type") String type); @Procedure @Description("apoc.nodes.get(node|nodes|id|[ids]) - quickly returns all nodes with these ids") Stream<NodeResult> get(@Name("nodes") Object ids); @Procedure(mode = Mode.WRITE) @Description("apoc.nodes.delete(node|nodes|id|[ids]) - quickly delete all nodes with these ids") Stream<LongResult> delete(@Name("nodes") Object ids, @Name("batchSize") long batchSize); @Procedure @Description("apoc.get.rels(rel|id|[ids]) - quickly returns all relationships with these ids") Stream<RelationshipResult> rels(@Name("relationships") Object ids); @UserFunction("apoc.node.relationship.exists") @Description("apoc.node.relationship.exists(node, rel-direction-pattern) - returns true when the node has the relationships of the pattern") boolean hasRelationship(@Name("node") Node node, @Name(value = "types", defaultValue = "") String types); @UserFunction("apoc.nodes.connected") @Description("apoc.nodes.connected(start, end, rel-direction-pattern) - returns true when the node is connected to the other node, optimized for dense nodes") boolean connected(@Name("start") Node start, @Name("start") Node end, @Name(value = "types", defaultValue = "") String types); @Procedure @Description("apoc.nodes.collapse([nodes...],[{properties:'overwrite' or 'discard' or 'combine'}]) yield from, rel, to merge nodes onto first in list") Stream<VirtualPathResult> collapse(@Name("nodes") List<Node> nodes, @Name(value = "config", defaultValue = "{}") Map<String, Object> config); @UserFunction("apoc.node.labels") @Description("returns labels for (virtual) nodes") List<String> labels(@Name("node") Node node); @UserFunction("apoc.node.id") @Description("returns id for (virtual) nodes") Long id(@Name("node") Node node); @UserFunction("apoc.rel.id") @Description("returns id for (virtual) relationships") Long relId(@Name("rel") Relationship rel); @UserFunction("apoc.rel.type") @Description("returns type for (virtual) relationships") String type(@Name("rel") Relationship rel); @UserFunction("apoc.any.properties") @Description("returns properties for virtual and real, nodes, rels and maps") Map<String,Object> properties(@Name("thing") Object thing, @Name(value = "keys",defaultValue = "null") List<String> keys); @UserFunction("apoc.any.property") @Description("returns property for virtual and real, nodes, rels and maps") Object property(@Name("thing") Object thing, @Name(value = "key") String key); @UserFunction("apoc.node.degree") @Description("apoc.node.degree(node, rel-direction-pattern) - returns total degrees of the given relationships in the pattern, can use '>' or '<' for all outgoing or incoming relationships") long degree(@Name("node") Node node, @Name(value = "types",defaultValue = "") String types); @UserFunction("apoc.node.degree.in") @Description("apoc.node.degree.in(node, relationshipName) - returns total number number of incoming relationships") long degreeIn(@Name("node") Node node, @Name(value = "types",defaultValue = "") String type); @UserFunction("apoc.node.degree.out") @Description("apoc.node.degree.out(node, relationshipName) - returns total number number of outgoing relationships") long degreeOut(@Name("node") Node node, @Name(value = "types",defaultValue = "") String type); @UserFunction("apoc.node.relationship.types") @Description("apoc.node.relationship.types(node, rel-direction-pattern) - returns a list of distinct relationship types") List<String> relationshipTypes(@Name("node") Node node, @Name(value = "types",defaultValue = "") String types); @UserFunction("apoc.nodes.relationship.types") @Description("apoc.nodes.relationship.types(node|nodes|id|[ids], rel-direction-pattern) - returns " + "a list of maps where each one has two fields: `node` which is the node subject of the analysis " + "and `types` which is a list of distinct relationship types") List<Map<String, Object>> nodesRelationshipTypes(@Name("ids") Object ids, @Name(value = "types",defaultValue = "") String types); @UserFunction("apoc.node.relationships.exist") @Description("apoc.node.relationships.exist(node, rel-direction-pattern) - returns a map with rel-pattern, boolean for the given relationship patterns") Map<String,Boolean> relationshipExists(@Name("node") Node node, @Name(value = "types", defaultValue = "") String types); @UserFunction("apoc.nodes.relationships.exist") @Description("apoc.nodes.relationships.exist(node|nodes|id|[ids], rel-direction-pattern) - returns " + "a list of maps where each one has two fields: `node` which is the node subject of the analysis " + "and `exists` which is a map with rel-pattern, boolean for the given relationship patterns") List<Map<String, Object>> nodesRelationshipExists(@Name("ids") Object ids, @Name(value = "types", defaultValue = "") String types); @UserFunction @Description("apoc.nodes.isDense(node) - returns true if it is a dense node") boolean isDense(@Name("node") Node node); @Context
    public GraphDatabaseService db; @Context
    public Transaction tx; @Context
    public KernelTransaction ktx; @Context
    public Pools pools; }
@Test public void testRelId() { assertTrue(TestUtil.<Long>singleResultFirstColumn(db, "CREATE (f)-[rel:REL {foo:'bar'}]->(f) RETURN apoc.rel.id(rel) AS id") >= 0); assertTrue(TestUtil.<Long>singleResultFirstColumn(db, "CREATE (f) WITH f CALL apoc.create.vRelationship(f,'REL',{foo:'bar'},f) YIELD rel RETURN apoc.rel.id(rel) AS id") < 0); assertNull(TestUtil.singleResultFirstColumn(db, "RETURN apoc.rel.id(null) AS id")); }