Graphs { @Description("apoc.graph.fromDocument({json}, {config}) yield graph - transform JSON documents into graph structures") @Procedure(mode = Mode.WRITE) public Stream<VirtualGraph> fromDocument(@Name("json") Object document, @Name(value = "config", defaultValue = "{}") Map<String,Object> config) throws Exception { DocumentToGraph documentToGraph = new DocumentToGraph(tx, new GraphsConfig(config)); return Stream.of(documentToGraph.create(document)); }  @Description("apoc.graph.fromData([nodes],[relationships],'name',{properties}) | creates a virtual graph object for later processing") @Procedure Stream<VirtualGraph> fromData(@Name("nodes") List<Node> nodes, @Name("relationships") List<Relationship> relationships, @Name("name") String name, @Name("properties") Map<String,Object> properties); @Description("apoc.graph.from(data,'name',{properties}) | creates a virtual graph object for later processing it tries its best to extract the graph information from the data you pass in") @Procedure Stream<VirtualGraph> from(@Name("data") Object data, @Name("name") String name, @Name("properties") Map<String,Object> properties); static boolean extract(Object data, Set<Node> nodes, Set<Relationship> rels); @Description("apoc.graph.fromPaths(path,'name',{properties}) - creates a virtual graph object for later processing") @Procedure Stream<VirtualGraph> fromPath(@Name("path") Path paths, @Name("name") String name, @Name("properties") Map<String,Object> properties); @Description("apoc.graph.fromPaths([paths],'name',{properties}) - creates a virtual graph object for later processing") @Procedure Stream<VirtualGraph> fromPaths(@Name("paths") List<Path> paths, @Name("name") String name, @Name("properties") Map<String,Object> properties); @Description("apoc.graph.fromDB('name',{properties}) - creates a virtual graph object for later processing") @Procedure Stream<VirtualGraph> fromDB(@Name("name") String name, @Name("properties") Map<String,Object> properties); @Description("apoc.graph.fromCypher('kernelTransaction',{params},'name',{properties}) - creates a virtual graph object for later processing") @Procedure Stream<VirtualGraph> fromCypher(@Name("kernelTransaction") String statement,  @Name("params") Map<String,Object> params,@Name("name") String name,  @Name("properties") Map<String,Object> properties); @Description("apoc.graph.fromDocument({json}, {config}) yield graph - transform JSON documents into graph structures") @Procedure(mode = Mode.WRITE) Stream<VirtualGraph> fromDocument(@Name("json") Object document, @Name(value = "config", defaultValue = "{}") Map<String,Object> config); @Description("apoc.graph.validateDocument({json}, {config}) yield row - validates the json, return the result of the validation") @Procedure(mode = Mode.READ) Stream<RowResult> validateDocument(@Name("json") Object document, @Name(value = "config", defaultValue = "{}") Map<String,Object> config); @Context
    public Transaction tx; }
@Test public void testFromDocument() throws Exception { Map<String, Object> artistGenesisMap = Util.map("type", "artist", "name", "Genesis", "id", 1L); Map<String, Object> albumGenesisMap = Util.map("type", "album", "producer", "Jonathan King", "id", 1L, "title", "From Genesis to Revelation"); Map<String, Object> artistGenesisMapExt = new HashMap() {{ putAll(artistGenesisMap); put("albums", Arrays.asList(albumGenesisMap)); }}; TestUtil.testResult(db, "CALL apoc.graph.fromDocument($json, $config) yield graph", Util.map("json", JsonUtil.OBJECT_MAPPER.writeValueAsString(artistGenesisMapExt), "config", Util.map("write", true)), stringObjectMap -> { Map<String, Object> map = stringObjectMap.next(); assertEquals("Graph", ((Map) map.get("graph")).get("name")); Collection<Node> nodes = (Collection<Node>) ((Map) map.get("graph")).get("nodes"); Collection<Relationship> relationships = (Collection<Relationship>) ((Map) map.get("graph")).get("relationships"); assertEquals(2, nodes.size()); assertEquals(1, relationships.size()); Iterator<Node> nodeIterator = nodes.iterator(); Iterator<Relationship> relationshipIterator = relationships.iterator(); Node albumGenesis = nodeIterator.next(); assertEquals(asList(label("Album")), albumGenesis.getLabels()); assertTrue(albumGenesis.getId() > 0); assertEquals(albumGenesisMap, albumGenesis.getAllProperties()); Node artistGenesis = nodeIterator.next(); assertEquals(asList(label("Artist")), artistGenesis.getLabels()); assertTrue(artistGenesis.getId() > 0); assertEquals(artistGenesisMap, artistGenesis.getAllProperties()); Relationship rel = relationshipIterator.next(); assertEquals("ALBUMS", rel.getType().name()); assertTrue(rel.getId() > 0); }); db.executeTransactionally("MATCH p = (a:Artist)-[r:ALBUMS]->(b:Album) detach delete p"); }