JSON Graphql Variables

Hi, I am Kausik. I am new to dgraph. I have a question/suggestion on how to implement Decision using dgraph. The decision output is user category (rich, vrich or avg)
Assume this scenario. There are few nodes of type user,cars and status and two types of Edge or relation(Rule and Decision)
The Rule or Edge connects user with cars nodes and cars nodes are connected to status nodes by Decision edge.
The Rule type edge contains brand as (Facets) {var:“brand”,val:“audi”}
The Decision type edge contains number of car owned. {var:“number”,val:2}
the last nodes type decides user category (rich, vrich or avg)

typically the query would be something like below to find user category.(incomplete)

{
    "query": "query test($a: {}) {
         me(func: type(user)) {
                   name    
                   rule @facet(type(rule){
                       
                    }
          }
       }
     }",
    "variables": {"brand":"Audi","number":2,duration:2}
}

visualisation untitled — ImgBB

This kind of functionality is available in Neo4j where you can pass JSON as param and iterate over all matching relationship and check it with json to get final decision.
Example of such neo4j cypher query : with {“brand”:“Audi”,“number”:2} as param MATCH p = (:user)-[*]->(endNode:decision) WHERE ALL (r in relationships§ WHERE r.val=param[r.var] ) return endNode

Please let me know for any clarification if required.

Welcome Kausik.
Dgraph does have some limitations on facets based filtering and IMO you may not be able to meet a rule engine type requirement using facets. Perhaps you could try to model the problem using types and attributes and let us know if you need any help.

Thank’s Anand.
Can you propose any work around for passing JSON object to query and iterating over it.

AFAIK, Graphql variables does not support arbitrary JSON.
Dgraph graphql API does support custom query where additional behavior can be configured. This involves writing your own logic and making it available in a service. Dgraph will invoke this service as a custom query. Please explore custom queries and its capabilities; it might be useful in this scenario.

Ok, Is there any thought or plan to implement such requirement in near future. I am sure many organisation moving to dgraph will analyse for a minimum set of feature before adopting. I also feel it is a general requirement nothing very specific.

Hi Kausik, thanks for sharing this feedback. This feature is currently not in our immediate plans. We will keep this feedback in our records and review again in future.