Skip to content

JSON mutation, Support facets for value edge lists #4581

@emile-tawfik

Description

@emile-tawfik

Hi,

This issue follows this one #4081 and this PR #4267.

#4267 changes the output format, but does not reflect thoses changes for the input JSON mutation format.

This cause 2 issues:

  • The JSON input and output are not permutable
  • This impossibility to add facets to a value edge lists

I think the JSON mutation format should be modified accordingly to the output format.

Below are some examples of the modified JSON input : (coming from #4081 (comment))

Facets on a singular value predicate

Schema:

<name>: string .

Old-Data:

{
    "name|kind": "first",
    "name": "Francesc"
}

Data:

{
    "name|kind": "first",
    "name": "Francesc"
}

Query:

{
   q(func: has(name)) {
      name @facets
   }
}

Result:

{
  "data": {
    "q": [
      {
        "name|kind": "first",
        "name": "Francesc"
      }
    ]
  }
}

Facets on lists of value predicates

Schema:

<nickname>: [string] .

Old-Data:

Impossible to write

Data:

{
    "nickname": [
      "Cesc",
      "Francesc",
      "Tete"
    ],
    "nickname|kind": {
      "0": "friends",
      "1": "official"
    }
}

Query:

{
   q(func: has(nickname)) {
      nickname @facets
   }
}

Result:

{
  "data": {
    "q": [
      {
        "nickname": [
          "Cesc",
          "Francesc",
          "Tete"
        ],
        "nickname|kind": {
          "0": "friends",
          "1": "official"
        }
      }
    ]
  }
}

Facets on a singular object predicate

Schema:

<name>: string .
<state>: uid .

Old-Data:

{
    "name": "San Francisco",
    "state": [
        {
            "name": "California",
            "state|capital": false
        }
    ]
}

Data:

{
    "name": "San Francisco",
    "state": [
      {
        "name": "California"
      },
      "state|capital": false
    ]
}

Query:

{
   q(func: has(state)) {
      name
      state @facets {
         name
      }
   }
}

Result:

{
  "data": {
    "q": [
      {
        "name": "San Francisco",
        "state": [
          {
            "name": "California"
          },
          "state|capital": false
        ]
      }
    ]
  }
}

Facets on a list of object predicates

Schema:

<name>: string .
<speaks>: [uid] .

Old-Data:

{
    "name": "Francesc",
    "speaks": [
      {
        "name": "Spanish",
        "speaks|fluent": true
      },
      {
        "name": "Chinese"
        "speaks|fluent": false
      }
    ]
}

Data:

{
    "name": "Francesc",
    "speaks": [
      {
        "name": "Spanish"
      },
      {
        "name": "Chinese"
      }
    ],
    "speaks|fluent": {
       "0": true,
       "1": false
    }
}

Query:

{
   q(func: has(state)) {
      name
      state @facets {
         name
      }
   }
}

Result:

{
  "data": {
    "q": [
      {
        "name": "Francesc",
        "speaks": [
          {
            "name": "Spanish"
          },
          {
            "name": "Chinese"
          }
        ],
        "speaks|fluent": {
           "0": true,
           "1": false
        }
      }
    ]
  }
}

Metadata

Metadata

Labels

area/facetsIssues related to face handling, querying, etc.area/mutationsRelated to mutations JSON or RDF.kind/bugSomething is broken.kind/featureSomething completely new we should consider.status/acceptedWe accept to investigate/work on it.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions