unlight/prisma-nestjs-graphql

optional fields in schema produce inconsistent orderBy types between required and optional scalar fields

scarrico-divergent opened this issue · 1 comments

After upgrading to v19 (to align with Prisma 5), we are experiencing issues with our existing graphql queries and query generation.

Our generated types have changed, specifically in the xxxOrderByWithRelationInput interfaces.

For example:

jiraData?: keyof typeof SortOrder;
jiraStatus?: InstanceType<typeof SortOrderInput>;

Previously we were on v18.0.2, which produced a class more like the below.

jiraData?: keyof typeof SortOrder;
jiraStatus?: keyof typeof SortOrder;

The required GQL query for sorting on jiraStatus is now orderBy: { jiraStatus: {sort: 'asc' }} instead of orderBy: {jiraStatus: 'asc'}}. This apepars to be in service of Prisma 4.16+ nullable sort feature https://www.prisma.io/docs/orm/prisma-client/queries/filtering-and-sorting#sort-with-null-records-first-or-last

However, Prisma appears to support either <field>: 'asc' or <field>: {sort: 'asc'} which this generated type does not. Can the type be relaxed to support either syntax if null sorting is not desired? It is difficult from the graphql query generation side to determine which fields to apply which syntax to.