How to do pattern match query in GraphQL?


(Cholerae Hu) #1

I can express my query in cypher like this:

match (b:buyer)-[:pay]-(i:ip)
match (s:seller)-[:register]-(i)
return b,i,s
limit 100

I can’t specify the start point of the query. How can I express this query in GraphQL?

Thanks in advance!


(Michael Compton) #2

Hi, thanks for the question.

It does however look like you are specifying the start point of the query - looks like it’s anything with type ‘buyer’. Is that right? Or is it matching anything that has edge pay?. Either way, the same thing is expressible in Dgraph’s GraphQL±.

Dgraph, however queries graphs and returns graphs, not tables, so the result won’t be expressed as b,i,s.

if you want things of a particular type (given our new types coming v1.1), it’s something like

func: type(buyer)

if you want to match things with particular edges, it’s

func: has(pay)

As for composing the answer, I’d need to know more about your schema to suggest a proper answer, but it could be something like

q(func: type(buyer)) {
  pay {
    ~register { ... }
  }
}