Skip to content

Problem with {} or undefined fields in aggregate and groupBy #242

@sergej-js

Description

@sergej-js

I get this error:
The select statement for type UserAvgAggregateOutputType needs at least one truthy value.

@Field(() => UserAvgAggregateInput, {nullable:true}) _avg?: UserAvgAggregateInput;

Even if you don't specify _avg in a GraphQL query, Nest may serialize it as undefined by default, while Prisma expects a valid object - and fails if either of these fields is present but empty.
This suggests filtering the arguments in service. Perhaps you should add the following from class-validator to the arguments for groupBy or aggregate
@ValidateIf(o => o._avg !== undefined)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions