Use same types as count for countDistinct (#14460)

This commit is contained in:
José Varela
2022-07-15 18:13:45 +01:00
committed by GitHub
parent 4b1854fe29
commit dc850c115e

View File

@@ -834,6 +834,18 @@ export class GraphQLService {
}, {} as ObjectTypeComposerFieldConfigMapDefinition<any, any>),
});
const countType = schemaComposer.createObjectTC({
name: `${collection.collection}_aggregated_count`,
fields: Object.values(collection.fields).reduce((acc, field) => {
acc[field.field] = {
type: GraphQLInt,
description: field.note,
};
return acc;
}, {} as ObjectTypeComposerFieldConfigMapDefinition<any, any>),
});
AggregateMethods[collection.collection] = {
group: {
name: 'group',
@@ -845,17 +857,11 @@ export class GraphQLService {
},
count: {
name: 'count',
type: schemaComposer.createObjectTC({
name: `${collection.collection}_aggregated_count`,
fields: Object.values(collection.fields).reduce((acc, field) => {
acc[field.field] = {
type: GraphQLInt,
description: field.note,
};
return acc;
}, {} as ObjectTypeComposerFieldConfigMapDefinition<any, any>),
}),
type: countType,
},
countDistinct: {
name: 'countDistinct',
type: countType,
},
};
@@ -879,10 +885,6 @@ export class GraphQLService {
name: 'sum',
type: AggregatedFields[collection.collection],
},
countDistinct: {
name: 'countDistinct',
type: AggregatedFields[collection.collection],
},
avgDistinct: {
name: 'avgDistinct',
type: AggregatedFields[collection.collection],