I have this datas structure:
{
"fieldNodes": [
{
"selectionSet": {
"selections": [
{
"name": {
"value": "id"
}
},
{
"name": {
"value": "phone"
}
},
{
"name": {
"value": "address"
},
"selectionSet": {
"selections": [
{
"name": {
"value": "street"
}
},
{
"name": {
"value": "city"
}
}
]
}
}
]
}
}
]
}
I need to go over the fieldNodes
array in recursion and create an array of strings of their value (name.value
).
The nested values will be represented by a dot ("address.city"
).
The results for this example will be: ["id", "phone", "address. street", "address.city"]
.
I'm assuming that I have one object in the fieldNodes
array.
Can someone please help me how the code should look like in NodeJS?