My query is find a company in the database, returns some basic information, and the financials information over the years. The result looks like:
{
"data": {
"company": {
"id": 1,
"name": "test company",
"companyType": "NH",
"financials": [
{
"year": 2018,
"netRevenue": 0,
"costOfSales": 0,
"grossProfit": 0,
"financialIncome": 0,
"financialExpenses": 0,
"resultOfOtherActivities": 0
},
{
"year": 2017,
"netRevenue": 0,
"costOfSales": 0,
"grossProfit": 0,
"financialIncome": 0,
"financialExpenses": 0,
"resultOfOtherActivities": 0
},
{
"year": 2016,
"netRevenue": 0,
"costOfSales": 0,
"grossProfit": 0,
"financialIncome": 0,
"financialExpenses": 0,
"resultOfOtherActivities": 0
}
]
}
}
}
Very simple to write the query:
{
company {
id
name
companyType
financials {
year
netRevenue
costOfSales
grossProfit
financialIncome
financialExpenses
resultOfOtherActivities
}
}
}
But my case is not so simple. I need a query just to retrieve some of the fields for each year. The result looks like:
{
"data": {
"company": {
"id": 1,
"name": "test company",
"companyType": "NH",
"financials": [
{
"year": 2018,
"netRevenue": 0
},
{
"year": 2017,
"grossProfit": 0,
"financialIncome": 0,
"financialExpenses": 0
},
{
"year": 2016,
"resultOfOtherActivities": 0
}
]
}
}
}
Is there any way that a query can achieve such a result?