getRules - Examples

In the following, an example request and the according response using the getRules endpoint are shown.

For testing, two rules-set are created by sending the requests below.

POST https://api.danube.ai/graphql

{
  "query": "mutation ($id: String!, $override: Boolean, $rules: [ClientRule]!) { setRules(id: $id, override: $override, rules: $rules) }",
  "variables": {
    "id": "test-rules-1",
    "override": true,
    "rules": [
      {
        "property": "p1",
        "type": "PERCENTAGE"
      },
      {
        "property": "p2",
        "type": "INVERSE_PERCENTAGE"
      }
    ]
  }
}

POST https://api.danube.ai/graphql

{
  "query": "mutation ($id: String!, $override: Boolean, $rules: [ClientRule]!) { setRules(id: $id, override: $override, rules: $rules) }",
  "variables": {
    "id": "test-rules-2",
    "override": true,
    "rules": [
      {
        "property": "p3",
        "type": "EQUALS",
        "equalityScores": [
          {
            "value": "v1",
            "score": 1
          },
          {
            "value": "v2",
            "score": 2
          }
        ]
      },
      {
        "property": "p4",
        "type": "OVERLAP_GLOBAL"
      }
    ]
  }
}

After that, the just created rules-sets can be retrieved by following request:

POST https://api.danube.ai/graphql

{
  "query": "query { getRules { id rules { property type equalityScores { value score } minRuleValue maxRuleValue clamping } } }"
}

Returns

{
  "data": {
    "getRules": [
      {
        "id": "test-rules-1",
        "rules": [
          {
            "property": "p1",
            "type": "PERCENTAGE",
            "equalityScores": null,
            "minRuleValue": null,
            "maxRuleValue": null,
            "clamping": null
          },
          {
            "property": "p2",
            "type": "INVERSE_PERCENTAGE",
            "equalityScores": null,
            "minRuleValue": null,
            "maxRuleValue": null,
            "clamping": null
          }
        ]
      },
      {
        "id": "test-rules-2",
        "rules": [
          {
            "property": "p3",
            "type": "EQUALS",
            "equalityScores": [
              {
                "value": "v1",
                "score": 1
              },
              {
                "value": "v2",
                "score": 2
              }
            ],
            "minRuleValue": null,
            "maxRuleValue": null,
            "clamping": null
          },
          {
            "property": "p4",
            "type": "OVERLAP_GLOBAL",
            "equalityScores": null,
            "minRuleValue": null,
            "maxRuleValue": null,
            "clamping": null
          }
        ]
      }
    ]
  }
}