Find by all inbound edges

I’m trying to implement tagging functionality.

Let’s say you have a node Metric that contains a name “cpu”.

You also have a node Tag that contains a name and value pair. For example, this could be “region=east” and “host=5”

Now I create these nodes and the Metric node has two edges from the two Tags. I want to be able to find the metric that contains both of these tags.

Another requirement would be if I only wanted to search for just “host=5”, how can I be sure that this Metric would not be returned? ( because it has multiple Tags, not just the one).

Is this possible in the GraphQL implementation?

Thanks!
Nick

Example: This should return the metric but it doesn’t return anything.

getProject(id: "1") {
    metric(filter: {name: {eq: "temp"}}) @cascade {
      tags(filter: {and: [{id: "0x4e52"}, {id: "0x4e53"}]}) {
        id
        name
        value
      }
      id
      name
    }
  }

It is with either doing it in multiple queries and logically combining the results on client side, or doing it in a custom DQL query using variable blocks. Note, that doing it with DQL bypasses any auth rules that you otherwise have in place in your GraphQL schema. There is a RFC over here that may interest you:

Thanks Anthony.

I took a look at the RFC and tried examples in DQL as well. I find that I can store the tags in a variable and then filter using uid however it is the Union and not a distinct set filter that I’m looking for. In the metric example above, all tags would have to be found with an edge to the metric. If there are more tags, then it would still work however if one is missing, then it shouldn’t match.

Example:
metric “cpu”
tags “region=east” “host=5”

I want to be able to query for “host=5” and have it return but if I query for “region=east AND host=6” it should not return.

What I came up with but it returns all metrics with either tag:

{ 
  tags as var(func: type(Tag)) @filter(
    (eq(Tag.name, "region") and eq(Tag.value, "east")) or 
    (eq(Tag.name, "host") and eq(Tag.value, "5"))) {
    uid 
    Tag.name
    Tag.value
  }
  metrics(func: type(Metric)) @cascade {
    uid 
    Metric.name 
    Metric.tags @filter(uid(tags)) {
      uid 
      Tag.name
      Tag.value
    }
  }
}

Can you point me to a way to accomplish this (DQL or GraphQL)?

I appreciate the help!