paljs / prisma-tools

Prisma tools to help you generate CRUD system for GraphQL servers
https://paljs.com
MIT License
683 stars 54 forks source link

Incorrect resolversTypes.ts code generation - "Client.AffectedRowsOutput" #177

Closed ZenSoftware closed 3 years ago

ZenSoftware commented 3 years ago

Hello @AhmedElywa!

Pal.js v2.12.0 seems to be producing the following:

resolversTypes.ts

...
export interface Mutation {
  [key: string]: Resolver<any, any, any>;
  createOneUser?: Resolver<{}, CreateOneUserArgs, Client.User>;
  upsertOneUser?: Resolver<{}, UpsertOneUserArgs, Client.User>;
  deleteOneUser?: Resolver<{}, DeleteOneUserArgs, Client.User | null>;
  updateOneUser?: Resolver<{}, UpdateOneUserArgs, Client.User | null>;
  updateManyUser?: Resolver<{}, UpdateManyUserArgs, Client.AffectedRowsOutput>; // Should not be accessed through Client
  deleteManyUser?: Resolver<{}, DeleteManyUserArgs, Client.AffectedRowsOutput>; // Should not be accessed through Client
}
...

Client.AffectedRowsOutput should simply be AffectedRowsOutput

By the way, I gave you a shout-out in the README of my most recent project. Thanks again!

⛩ Zen ⛩ Nest + Prisma + Angular 🏮 Full Stack Starter Kit

ZenSoftware commented 3 years ago

After manually removing the Client from AffectedRowsOutput, I am getting the following Typescript compilation error:

[0]   Type 'Promise<BatchPayload>' is not assignable to type 'Promise<AffectedRowsOutput>'.
[0] ERROR in C:/a/Work/oss/apps/api/src/app/graphql/prisma/User/resolvers.ts(35,5):
[0] TS2322: Type '(_parent: {}, args: DeleteManyUserArgs, { prisma }: IContext) => Promise<BatchPayload>' is not assignable to type 'Resolver<{}, DeleteManyUserArgs, AffectedRowsOutput>'.
[0]   Type 'Promise<BatchPayload>' is not assignable to type 'Promise<AffectedRowsOutput>'.
[0] ERROR in C:/a/Work/oss/apps/api/src/app/graphql/prisma/User/resolvers.ts(39,5):
[0] TS2322: Type '(_parent: {}, args: UpdateManyUserArgs, { prisma }: IContext) => Promise<BatchPayload>' is not assignable to type 'Resolver<{}, UpdateManyUserArgs, AffectedRowsOutput>'.