Open SebaBoler opened 2 years ago
There seems to be a bug in the latest version preventing order and possibly pagination to work - extra negation in function isPrimitive
in file is-primitive.ts
, which probably shouldn't be there.
You can use older version (1.3.0), until it is fixed.
NestJs + GraphQl + TypeOrm and resolver Query :
@Query(() => [Department]) async getDepartments( @Args() args: DepartmentArgs, @Args() orderByArgs: OrderByArgs, // @Args() paginationArgs: PaginationArgs, @Info() info: GraphQLResolveInfo, ): Promise<Department[]> { return await PerchQueryBuilder.find<Department>( this.departmentRepository, info, ); }
query GetDepartments($orderAscBy: String) { getDepartments( _orderAscBy: $orderAscBy) { departmentId departmentUUID departmentShortName departmentFullName isActive } }
{ "orderAscBy": "departmentId" }
Response
{ "data": { "getDepartments": [ { "departmentId": 2, "departmentUUID": "ffed96d2-d1a6-47f3-b65d-c03b3b3e0fcb", "departmentShortName": "Area2", "departmentFullName": "Area2 name", "isActive": false }, { "departmentId": 1, "departmentUUID": "3ed9d9db-ecde-4459-9b43-c61b5603ddee", "departmentShortName": "Area1", "departmentFullName": "Area2 name", "isActive": false } ] } }
Order by departmentId asc doent work.
In log of Graphql i dont see any order by in select
query: SELECT "Department"."departmentId" AS "Department_departmentId", "Department"."departmentUUID" AS "Department_departmentUUID", "Department"."departmentShortName" AS "Department_departmentShortName", "Department"."departmentFullName" AS "Department_departmentFullName", "Department"."isActive" AS "Department_isActive" FROM "public"."Department" "Department"