greskell icon indicating copy to clipboard operation
greskell copied to clipboard

Question on 'where' clause with incoming edges

Open catchvoid opened this issue 1 year ago • 1 comments

Hi,

Thanks for making greskell available! I really enjoy using the DSL, and I appreciate the addition of Data.Greskell.GTraversal.Gen—it’s made working with it much more pleasant.

I’m currently struggling with replicating a where condition to test if a vertex has an incoming edge with a specific label. Here's the query I’m trying to translate:

g.V().has("person", "person_id", personId)
.out("lives")
.in("within")
.where(inE("about"))
.group()...

The full query can be found in this example:
Graph Databases in Action – Chapter 8 Example

What’s the best way to write this in greskell?

Thanks!

catchvoid avatar Dec 22 '24 23:12 catchvoid

Hi! Here is the incomplete translation to greskell.

example :: GTraversal Transform () AVertex
example = source "g" & sV [] &. gHasLabel "person" &. gHas2 "person_id" personId
          &. gOut ["lives"]
          &. gIn ["within"]
          &. gFilter (gInE ["about"])

Note:

  • You might need some type annotations (to resolve type ambiguity) and liftWalk calls (to match the walk type).
  • greskell doesn't support .has(label, key, value) step yet. It's equivalent to .hasLabel(label).has(key, value).
  • greskell doesn't support .where(traversal) step yet. I think it's equivalent to .filter(traversal).
  • greskell doesn't support .group step yet. For now, you need to use unsafeWalk to write it in greskell.

debug-ito avatar Dec 25 '24 02:12 debug-ito