Consult a query in dgraph

What I want to do

how can i get ip in query?

{
  var (func: type(Machine)) @filter(eq(ip,"10.194.11.11")){
        server_node as ~SERVICE_on 
  }
    
  var (func: uid(server_node)) {
      docker_ip as ip
      ~SERVICE_on {
        skip_app as ~HAVE_groups
      }
  }
  
  query(func: uid(skip_app)){
    ip:val(docker_ip)
    app_name
  }
}

The above query statement can only get app_name.
The node relationship is as follows:
Machine <— Docker <— group <— app
parameter:
IP in machine
return:
ip in Docker and the app_name in app

Dgraph metadata

dgraph version

20.11

I have made a couple assumptions about your data but how about this?

{
  q(func: type(Machine)) @filter(eq(ip,"10.194.11.11")) @normalize {
    machine_ip: ip
    ~SERVICE_on {
      docker_ip: docker_ip
      ~HAVE_groups {
        app_name: app_name
      }
    }
  }
}

you have docker_ip and app_name on the same level in your version, so I added normalize to do that here - it can be removed if that is not a requirement.

(edit: also did not know if you truly meant two SERVICE_on edges. If so, you can add it back there)