-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GroupBy Argument Type required parameter follows an optional parameter #229
Comments
Some generated graphql classes (input/output) may not be compatible with prisma types. You must adapt it. |
It's not the problem, that some generated graphql classes are not compatible with prisma types. The fields of the generated Current generated class: @ArgsType()
export class UserGroupByArgs {
@Field(() => UserWhereInput, { nullable: true })
@Type(() => UserWhereInput)
where?: InstanceType<typeof UserWhereInput>;
@Field(() => [UserOrderByWithAggregationInput], { nullable: true })
orderBy?: Array<UserOrderByWithAggregationInput>;
@Field(() => [UserScalarFieldEnum], { nullable: false }) // <-- Required field after optional fields
by!: Array<`${UserScalarFieldEnum}`>;
@Field(() => UserScalarWhereWithAggregatesInput, { nullable: true })
having?: InstanceType<typeof UserScalarWhereWithAggregatesInput>;
@Field(() => Int, { nullable: true })
take?: number;
@Field(() => Int, { nullable: true })
skip?: number;
@Field(() => UserCountAggregateInput, { nullable: true })
_count?: InstanceType<typeof UserCountAggregateInput>;
@Field(() => UserAvgAggregateInput, { nullable: true })
_avg?: InstanceType<typeof UserAvgAggregateInput>;
@Field(() => UserSumAggregateInput, { nullable: true })
_sum?: InstanceType<typeof UserSumAggregateInput>;
@Field(() => UserMinAggregateInput, { nullable: true })
_min?: InstanceType<typeof UserMinAggregateInput>;
@Field(() => UserMaxAggregateInput, { nullable: true })
_max?: InstanceType<typeof UserMaxAggregateInput>;
} Class as it should be generated: @ArgsType()
export class UserGroupByArgs {
@Field(() => [UserScalarFieldEnum], { nullable: false }) // <-- Required field at first
by!: Array<`${UserScalarFieldEnum}`>;
@Field(() => UserWhereInput, { nullable: true })
@Type(() => UserWhereInput)
where?: InstanceType<typeof UserWhereInput>;
@Field(() => [UserOrderByWithAggregationInput], { nullable: true })
orderBy?: Array<UserOrderByWithAggregationInput>;
@Field(() => UserScalarWhereWithAggregatesInput, { nullable: true })
having?: InstanceType<typeof UserScalarWhereWithAggregatesInput>;
@Field(() => Int, { nullable: true })
take?: number;
@Field(() => Int, { nullable: true })
skip?: number;
@Field(() => UserCountAggregateInput, { nullable: true })
_count?: InstanceType<typeof UserCountAggregateInput>;
@Field(() => UserAvgAggregateInput, { nullable: true })
_avg?: InstanceType<typeof UserAvgAggregateInput>;
@Field(() => UserSumAggregateInput, { nullable: true })
_sum?: InstanceType<typeof UserSumAggregateInput>;
@Field(() => UserMinAggregateInput, { nullable: true })
_min?: InstanceType<typeof UserMinAggregateInput>;
@Field(() => UserMaxAggregateInput, { nullable: true })
_max?: InstanceType<typeof UserMaxAggregateInput>;
} |
Weird. 😕 |
Tested on graphql query query {
groupByUser(
orderBy: [{ name: asc }]
by: [id, name]
)
{
id
name
}
}
|
I created a minimal reproduction project. You can find it here. I noticed that I used that the However, I get still an error on the @Query(() => [UserGroupBy])
async groupByUser(
@Args() groupByArgs: UserGroupByArgs,
): Promise<UserGroupBy[]> {
const userGroupByArgs: Prisma.UserGroupByArgs = groupByArgs;
// TODO: Does not work without @ts-ignore
return this._prisma.user.groupBy(userGroupByArgs);
} You can search for |
Looks like you are facing this issue prisma/prisma#17297 |
I see different error: Type of property 'AND' circularly references itself in mapped type '{ [K in keyof { AND?: BlogPostScalarWhereWithAggregatesInput | BlogPostScalarWhereWithAggregatesInput[]; ... 9 more ...; authorId?: number | IntNullableWithAggregatesFilter<...>; }]: Or<...> extends 1 ? { ...; }[K] extends infer TK ? GetHavingFields<...> : never : {} extends FieldPaths<...> ? never : K; }' |
Hey,
the required property
by
follows the optional parameterswhere
andorderBy
, which results in an error on the generated typescript definition file from NestJs.Example to reproduce:
You will get following error in generated typescript definitions file:
My versions:
The text was updated successfully, but these errors were encountered: