With a sample make it easy understand, with https://developer.github.com/v4/explorer/
query the viewer info:
query {
viewer {
followers {
totalCount
}
following {
totalCount
}
}
}
the result is:
{
"data": {
"viewer": {
"followers": {
"totalCount": 131
},
"following": {
"totalCount": 28
}
}
}
}
what I want is:
{
"data": {
"viewer": {
"followersCount" 131,
"followingCount": 28
}
}
}
so does GraphQL support this ? and how to do it?
FLATTEN is a table function that takes a VARIANT, OBJECT, or ARRAY column and produces a lateral view (i.e. an inline view that contains correlation referring to other tables that precede it in the FROM clause). FLATTEN can be used to convert semi-structured data to a relational representation.
The brackets are required if you use keywords or special chars in the column names or identifiers. You could name a column [First Name] (with a space) – but then you'd need to use brackets every time you referred to that column. The newer tools add them everywhere just in case or for consistency.
GraphQL doesn't support this type of data flattening.
You must change the data structure in your code or work with the returned data structure.
EDIT: I just came across this repository (graphql-lodash) that could help you achieve what you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With