Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indirect prisma relations has type errors. #1184

Open
charleslai2000 opened this issue Apr 7, 2024 · 3 comments
Open

Indirect prisma relations has type errors. #1184

charleslai2000 opened this issue Apr 7, 2024 · 3 comments

Comments

@charleslai2000
Copy link

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.

@hayes
Copy link
Owner

hayes commented Apr 7, 2024

Have you rerun Prisma generate after upgrading?

@charleslai2000
Copy link
Author

Yes, I have re-run the generate command.

@hayes
Copy link
Owner

hayes commented Apr 15, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants