Cauen / prisma-generator-pothos-codegen

The fastest way to create a fully customizable CRUD Graphql API from Prisma Schema.
https://www.npmjs.com/package/prisma-generator-pothos-codegen
95 stars 16 forks source link

Use 'ID' type for prisma fields decorated with @id attribute #50

Closed hbendev closed 1 year ago

hbendev commented 1 year ago

I would expect the generated Input objects to have 'ID' scalar as their type instead of String - at least if they they are string types in the db, but maybe other times as well to comply the GraphQL specification.

Related docs: https://graphql.org/learn/schema/#scalar-types

Example schema file:

model User {
  id                    String                  @id @default(cuid()) @db.VarChar(30)
  createdAt             DateTime                @default(now())
  updatedAt             DateTime                @updatedAt
  isAdmin               Boolean                 @default(false)
  email                 String                  @unique
}

Actual output:

export const UserWhereUniqueInputFields = (t: any) => ({
  id: t.string({"required":false}),
  email: t.string({"required":false}),
});

Expected output:

export const UserWhereUniqueInputFields = (t: any) => ({
  id: t.id({"required":false}),
  email: t.string({"required":false}),
});
Cauen commented 1 year ago

Merged. Thanks @hbendev Its now a option "config.inputs.mapIdFieldsToGraphqlId"