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

DistinctFieldEnum still being generated instead of ScalarFieldEnum #163

Closed ZenSoftware closed 3 years ago

ZenSoftware commented 3 years ago

Hello @AhmedElywa ,

@paljs/cli v2.9.1 seems to still be generating the old style of type names for enums before the change in @prisma/client v2.13.0. In some places they seem to be correctly generating with the new ScalarFieldEnum postfix, though in other places they are still generating with the old DistinctFieldEnum postfix.

Contact/typeDefs.ts

type Query {
    type Contact {
    id: Int!
    firstName: String!
    lastName: String
    csvUnits(
      where: CsvUnitWhereInput
      orderBy: CsvUnitOrderByInput
      cursor: CsvUnitWhereUniqueInput
      take: Int
      skip: Int
      distinct: CsvUnitScalarFieldEnum # Correct ^_^
    ): [CsvUnit!]!
  }

  type Query {
    findUniqueContact(where: ContactWhereUniqueInput!): Contact
    findFirstContact(
      where: ContactWhereInput
      orderBy: [ContactOrderByInput!]
      cursor: ContactWhereUniqueInput
      distinct: ContactDistinctFieldEnum # Incorrect
      skip: Int
      take: Int
    ): [Contact!]
    findManyContact(
      where: ContactWhereInput
      orderBy: [ContactOrderByInput!]
      cursor: ContactWhereUniqueInput
      distinct: ContactDistinctFieldEnum # Incorrect
      skip: Int
      take: Int
    ): [Contact!]
    findManyContactCount(
      where: ContactWhereInput
      orderBy: [ContactOrderByInput!]
      cursor: ContactWhereUniqueInput
      distinct: ContactDistinctFieldEnum # Incorrect
      skip: Int
      take: Int
    ): Int!
    aggregateContact(
      where: ContactWhereInput
      orderBy: [ContactOrderByInput!]
      cursor: ContactWhereUniqueInput
      distinct: ContactDistinctFieldEnum # Incorrect
      skip: Int
      take: Int
    ): AggregateContact
  }
   ...
}

schema.prisma

...
model Contact {
  id          Int       @id @default(autoincrement())
  firstName   String
  lastName    String?

  csvUnits    CsvUnit[]
}

model CsvUnit {
  id            Int     @id @default(autoincrement())
  unit          String?
  address       String?
  owners        String?
  ownersParsed  CsvContact[]
  ownerAddress  String?
  contactInfos  String?
  tenants       String?
  vehicles      String?
  parking       String?

  contacts      Contact[]
}
...
AhmedElywa commented 3 years ago

Thanks for report

ZenSoftware commented 3 years ago

That fixed it! Thanks again ^_^