Aggregation doesn work as intended
fabianboerner opened this issue · 4 comments
Having one query
query {
statEntryAggregate {
sum {
Clicks
Impressions
}
}
}
getting follwing result
{
"data": {
"statEntryAggregate": [
{
"sum": {
"Clicks": 0,
"Impressions": 0
}
}
]
}
}
But the data behind it:
{
"data": {
"statEntries": {
"edges": [
{
"node": {
"campaignId": "d6b257f6-8749-4492-9a36-993f0930af8d",
"Clicks": 0,
"Impressions": 9,
"Conversions": 0,
"Spend": {
"value": 6.5
},
"positionId": "2d6f479d-fe8e-4560-8fe6-00f3f8eea39c",
"channelAlias": "xxxxx",
"organicImpressions": 0,
"organicClicks": 0,
"organicApplyStarts": 0,
"jobReferenceNumber": "12345"
}
},
{...
To Reproduce
Steps to reproduce the behavior:
- Create aggregate graphql implementation
- Query aggregate
Expected behavior
Impression would show 9 instead of 0
Screenshots
If applicable, add screenshots to help explain your problem.
Thanks for reporting, would it be possible for you to add a test case to this repo reproducing this? (Inside ./examples)
Not sure i will find the time currently.
What i saw that the service of a crudresolver as described in the documentation is incompatible with the base class
import { QueryService, InjectQueryService } from '@nestjs-query/core';
import { CRUDResolver } from '@nestjs-query/query-graphql';
import { Resolver, Query, Args } from '@nestjs/graphql';
import { TodoItemDTO } from './dto/todo-item.dto';
import { TodoItemEntity } from './todo-item.entity';
@Resolver(() => TodoItemDTO)
export class TodoItemResolver extends CRUDResolver(TodoItemDTO) {
constructor(
@InjectQueryService(TodoItemEntity) readonly service: QueryService<TodoItemEntity>
) {
super(service);
}
}
if its like that, it works
import { QueryService, InjectQueryService } from '@nestjs-query/core';
import { CRUDResolver } from '@nestjs-query/query-graphql';
import { Resolver, Query, Args } from '@nestjs/graphql';
import { TodoItemDTO } from './dto/todo-item.dto';
import { TodoItemEntity } from './todo-item.entity';
@Resolver(() => TodoItemDTO)
export class TodoItemResolver extends CRUDResolver(TodoItemDTO) {
constructor(
@InjectQueryService(TodoItemEntity) readonly service: QueryService<TodoItemDTO>
) {
super(service);
}
}
same probleam
const res = await this.aggregate(query.filter, {
count: [
{
field: 'id',
args: null,
},
],
sum: [
{
field: 'amount',
args: {},
},
{
field: 'fee',
args: {},
},
],
});
I got sum 0 However, the same criteria can be filtered in the database for two items. equals 20
BTW , the sum field is typeof string number in my database.