Hi guys!
I really like this Module so far. One thing bothers me though:
the returned data from GraphQL is kinda "messy", e.g. if i have only one element returned from a list operation,
I don't want it to be returned as an array holding one element, but instead just return the one object instead.
I've written a quick and dirty JS function, which transforms the data I receive into the format described above.
transformGqlResponse (response, pagename) {
const data = response.data[pagename]
const content = data.list[0]
for (const item in content) {
if (Object.prototype.hasOwnProperty.call(content[item], 'list')) {
content[item] = content[item].list[0]
}
}
return content
}
Obviously this poses a problem for deeply nested list operations.
Is there a way to transform the data like that before it is returned to my frontend, like make the list operation return the object instead of an array when the list operation result only yields one item?
Also first post, LOL.