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

resolversTypes.ts doesn't properly handle fields with the same name but different types #187

Closed ahollenbach closed 3 years ago

ahollenbach commented 3 years ago

Hi all! Running into an issue with the generation of resolversTypes.ts for the SDL generator.

(property) FeaturesArgs.cursor?: ElementAWhereUniqueInput

Subsequent property declarations must have the same type.  Property 'cursor' must be of type 'ElementAWhereUniqueInput', but here has type 'ElementBWhereUniqueInput'.ts(2717)
resolversTypes.ts(8851, 3): 'cursor' was also declared here.

Because everything is dropped into the resolversTypes.ts file, there are several collisions where the same interface is exported. Example that generates the above error message:

// resolversTypes.ts

// Generated for use with Foo.features
export interface FeaturesArgs {
  where?: ElementAWhereInput | null
  orderBy?: ElementAOrderByInput[] | null
  cursor?: ElementAWhereUniqueInput | null
  take?: number | null
  skip?: number | null
  distinct?: ElementAScalarFieldEnum[] | null
}

// Generated for use with Bar.features
export interface FeaturesArgs {
  where?: ElementBWhereInput | null
  orderBy?: ElementBOrderByInput[] | null
  cursor?: ElementBWhereUniqueInput | null
  take?: number | null
  skip?: number | null
  distinct?: ElementBScalarFieldEnum[] | null
}

The associated models in the schema.prisma file contain the same feature attribute, but of different types

// schema.prisma

model Foo {
  features  ElementA[]
}

model Bar {
  features  ElementB[]
}