Broken Prisma query is generated by swagger UI when the query is a nested object
Is there an existing issue for this?
- [X] I have searched the existing issues
Current behavior
I have an application written with Nestjs, Prisma, GraphQL, and when I try to make a query with a form of a nested object the query is sent in the wrong format.
For example the API request: GET /api/users
@common.Get()
@nestAccessControl.UseRoles({
resource: "User",
action: "read",
possession: "any",
})
@swagger.ApiOkResponse({ type: [User] })
@swagger.ApiForbiddenResponse()
@swagger.ApiQuery({
type: () => UserFindManyArgs,
style: "deepObject",
explode: true,
})
async findMany(
@common.Req() request: Request,
@nestAccessControl.UserRoles() userRoles: string[]
): Promise<User[]> {
const args = plainToClass(UserFindManyArgs, request.query);
const permission = this.rolesBuilder.permission({
role: userRoles,
action: "read",
possession: "any",
resource: "User",
});
const results = await this.service.findMany({
...args,
select: {
id: true,
createdAt: true,
updatedAt: true,
firstName: true,
lastName: true,
username: true,
roles: true,
profile: {
select: {
id: true,
},
},
},
});
return results.map((result) => permission.filter(result));
}

When I log the generated query I get the following output:
{
"firstName": {
"equals": "string",
"in": [
"string"
],
"notIn": [
"string"
],
"lt": "string",
"lte": "string",
"gt": "string",
"gte": "string",
"contains": "string",
"startsWith": "string",
"endsWith": "string",
"mode": "Default",
"not": "string"
},
..... and the rest of the query from the where input property
Minimum reproduction code
https://github.com/abrl91/amp-temp/blob/main/server/src/user/base/user.controller.base.ts#L110
Steps to reproduce
docker compose -d go to localhot:3000/api
Expected behavior
We can see that is missing the parameter name where at the beginning of the sample.
I expected to get:
+ {where:
{
"firstName": {
"equals": "string",
"in": [
"string"
],
"notIn": [
"string"
],
"lt": "string",
"lte": "string",
"gt": "string",
"gte": "string",
"contains": "string",
"startsWith": "string",
"endsWith": "string",
"mode": "Default",
"not": "string"
},
+}
We can see that regarding the skip and take (both type number) the URL generated as expected

Package version
5.1.5
NestJS version
8.2.3
Node.js version
14.17.3
In which operating systems have you tested?
- [X] macOS
- [ ] Windows
- [ ] Linux
Other
I found a solution for how to solve it and I would like to try to add this solution as a decorator to nestjs/swagger and hope someone could guide me on how to test my solution.