Expended edges as string list


(Stefan Fransen) #1

Hey,

I was wondering if its possible to render edges with single value as a list type instead of a object array.
The reason behind this is I’ve got images saved with an hash used for searching by image.

At the moment I’m modifying my JSON at the edge, this works fine but isn’t the cleanest solution.

My query:

{
  product(func: uid(0x70980)) {
    name : <http://schema.org/name>
    description : <http://schema.org/description>
    image {
      url
    }
  }
}

Output:

{
  "product": [
    {
      "name": "Bissell Multi-oppervlaktereiniger",
      "description": "De veelzijdige CrossWave stofzuigt, dweilt en helpt bij het drogen van vloeren. \n- zowel natte als droge reiniging \n- geen stofzak",
      "image": [
        {
          "url": "https://www.alternate.nl/p/450x450/n/ntzrza9k_30.jpg"
        },
        {
          "url": "https://www.alternate.nl/p/450x450/1/1ss9a04z_30.jpg"
        },
        {
          "url": "https://www.alternate.nl/p/450x450/9/9gsheq09_30.jpg"
        }
      ]
    }
  ]
}

Wanted output:

{
  "product": [
    {
      "name": "Bissell Multi-oppervlaktereiniger",
      "description": "De veelzijdige CrossWave stofzuigt, dweilt en helpt bij het drogen van vloeren. \n- zowel natte als droge reiniging \n- geen stofzak",
      "image": [
        "https://www.alternate.nl/p/450x450/n/ntzrza9k_30.jpg",
        "https://www.alternate.nl/p/450x450/1/1ss9a04z_30.jpg",
        "https://www.alternate.nl/p/450x450/9/9gsheq09_30.jpg"
      ]
    }
  ]
}

Is there any functionality like this currently in Dgraph? If not, I gladly create a PR if there is interest.

Thanks!
Stefan Fransen


(Michel Conrado (Support Engineer)) #2

Nops

Can be interesting tho. The only similar way would be using List ( eg in JSON )- If you create a directive (like @Normalize) to convert the edges into a list would be interesting and welcome feature.

PS.

This feature would be advantageous. Because it would allow you to use other features that are not possible with [List]. As for example language system, Facets, ordering and etc.
e.g:

{
  product(func: uid(0x70980)) {
    name : <http://schema.org/name>
    description : <http://schema.org/description> 
    image @facets(eq(region, "us-east-1")) @toList(url) {
      url
    }
  }
}

Cheers.