Feature Request: Ordered Arrays

Continuing the discussion from Schema for maps of kv pairs with variant values:

It would be nice if there was a way to store an ordered set without a messy or concatenating a string to reorder in a UI.

Dgraph supports [String] but it is somewhat uncommon knowledge that they work like a set with one gotcha (order)

  • Dgraph arrays do not store duplicates
  • Dgraph arrays do not store order

This is understandable given the API generated. Removing by value could potentially remove more than one, if they did not work as a set. And adding a value repeatedly could add duplicates when that is not desired.

However sometimes that is the desired structure of arrays. To store duplicates and to store order. How can this be done in Dgraph right now?

Through very messy schema.

Instead of

type Person {
  actions: [String]

In order to handle duplicates and order, it has to become:

type Person {
  actions: [Action]

type Action {
  id: ID
  order: Int
  action: String

This then becomes harder to work with now that users have to transform data from a simple array in the UI to arrays of objects with extra parameters.

What is really wanted sometimes is to store this exactly:

  "Person": {

For Reference. Acknowledges as GraphQL spec compliance: