pothos icon indicating copy to clipboard operation
pothos copied to clipboard

Indirect prisma relations has type errors.

Open charleslai2000 opened this issue 1 year ago • 3 comments

When upgrade to 3.64.0 of @pothos/plugin-prisma, typescript report a type error for every indirect relations. A sample code is below:


export const ConceptNode = builder.prismaNode('Concept', {
  description: 'Concept information',
  // https://pothos-graphql.dev/docs/plugins/prisma#select-mode-for-types
  select: { id: true },
  // https://pothos-graphql.dev/docs/plugins/prisma#prismanode
  id: { field: 'id' },
  fields: t => ({
    version: t.exposeString('version', { description: 'Concept version' }),
    type: t.expose('type', {
      description: 'Concept type',
      type: ConceptCategoryEnum,
    }),
    name: t.exposeString('name', { description: 'Concept name' }),
    abbreviation: t.exposeString('abbreviation', { description: 'Concept abbreviation' }),
    description: t.exposeString('description', { description: 'Concept description' }),
    // https://pothos-graphql.dev/docs/plugins/prisma#indirect-relations-eg-join-tables
    superiors: t.field({
      description: 'Superior concepts',
      select: (args, ctx, nestedSelection) => ({
        superiors: {
          select: {
            superior: nestedSelection(true),
          },
        },
      }),
      type: [ConceptNode],
      resolve: concept => concept.superiors.map(({ superior }) => superior),
    }),
  }),
})

The select field of superiors field report error: Type '{ superiors: { select: { superior: true; }; }; }' is not assignable to type 'never'.ts(2322)

Please check this. My whole project can not compile now.

charleslai2000 avatar Apr 07 '24 09:04 charleslai2000

Have you rerun Prisma generate after upgrading?

hayes avatar Apr 07 '24 16:04 hayes

Yes, I have re-run the generate command.

charleslai2000 avatar Apr 13 '24 16:04 charleslai2000

I haven't been able to replicate this in any of the repos I have that use the Prisma plugin. Is there a reproduction you might be able to share?

hayes avatar Apr 15 '24 22:04 hayes

Let me know if you are still having issues, but since Ive been unable to reproduce, and haven't gotten any more info here, I am hoping this has been resolved. I'm going to close this out for now.

hayes avatar Jul 10 '24 16:07 hayes

The issue is disappeared after I installed the latest version, Thanks.

charleslai2000 avatar Jul 16 '24 15:07 charleslai2000