Moved from GitHub dgraph/2807
Posted by stefanfransen:
Hi, for my use case I’ve got images saved to products as an edge.
I can’t use string lists because I’m saving a hash with the image used for image based searches.
Often I need to only get the image URLs when retrieving a product, at the moment this adds an unnecessary object for every image.
Discussion with some interesting ideas by @MichelDiz
What you wanted to do
I want to get this 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"
]
}
]
}
With the following query:
{
product(func: uid(0x70980)) {
name : <http://schema.org/name>
description : <http://schema.org/description>
image {
url
}
}
}
What you actually did
This is the output I got.
{
"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"
}
]
}
]
}
So at the moment I’m modifying this output of objects into a array of strings.
Why that wasn’t great, with examples
This adds extra unnecessary code.
Any external references to support your case
No references, think the reason for a function that minimizes the output is always a great addition
If this a feature more people are interested in I would love to open a PR for this.
Let me know what your thoughts are.
Stefan Fransen.