Return all the graph with relations


I use spring data neo4j and i have the code like :

public class VmEntity {

    Long id;

    String name;

    List<String> nodeLabels;

    @Relationship(type = "CONTAINS", direction = Relationship.INCOMING)
    private List<ClusterEntity> clusters = new ArrayList<>();

and repository like :

public interface VmRepository extends Neo4jRepository<VmEntity, Long> {

    Optional<VmEntity> findByName(String name);

    @Query("MATCH (n {name:$name}) " +
            "WHERE 'VM' IN labels(n) " +
            "REMOVE n:Alert " +
            "RETURN n")
    VmEntity removeAlertLabel(String name);

    @Query("MATCH (n) " +
            "RETURN n")
    Result getTheGraph();

    public class Result{
        List<Node> nodes;
        List<Link> links;

I want to know how can i return all the graph like "MATCH (n) RETURN n " and transform result to an object :

nodes: [{id: 1, name: "N1"}, {id: 2, name: "N2"}],
  links : [{source: "N1", target: "N2"}]

Thank you