Using uid_in to filter by two edges away?

Is it possible to use uid_in to filter results based on a node that is two edges away?

For instance, given three types, Map, Pin, and Route

  • A Map can contain any number of Pins. pred: map_has_pin
  • A Route can contain any number of Pins. pred: route_has_pin
  • (There are no edges from Route to Map)

Can I create a query that finds all Routes that are in a map? (By seeing if any of that Route’s Pins are used in the Map in question)

Something like this:

{
  routes(func: eq(type, "route"))
  	@filter(uid_in(route_has_pin.~map_has_pin, 0xaf11))
  {
    uid
    title
  }
}

Sorry, figured it out!

{
  var(func: uid(0xaf11)) {    
    has_pin {
      A as ~includes_pin
    }
  }
  routesWithinMap(func: uid(A)) {
    uid
    includes_pin {  # pins within this route
      ~has_pin {    # maps this pin belongs to
      	   uid      # as expected, this is always "0xaf11"
    	}
    }
  }
}

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.