Prisma-client-js: Type issue when try to make where or orderBy inside select

Created on 12 Mar 2020  Â·  4Comments  Â·  Source: prisma/prisma-client-js

Here when i make query

image

here i have selected them and give me error
image

if i delete where and orderBy issue is gone

image

my version 2.0.0-preview024 it's from it because i just back to 2.0.0-preview023 and problem solved

bu0-needs-info kinbug

Most helpful comment

Hi @AhmedElywa

Can you please give a minimal reproduction of this? Otherwise please share your datamodel and the client queries. It is quite time consuming to reproduce with screenshots as you can't copy code.

All 4 comments

Same problem here, tested it also with https://github.com/prisma/prisma-examples/tree/prisma2/typescript/graphql

When modifying schema.ts:

t.list.field('feed', {
      type: 'Post',
      resolve: async (_parent, _args, ctx) => {
        const posts = await ctx.prisma.post.findMany({
          where: { published: true },
          include: {
            author: {
              include: {
                posts: { orderBy: { title: 'asc' }, include: { author: true } },
              },
            },
          },
        })
        const test = posts[0].author?.posts[0].author
        return posts
      },
    })

then the type of posts is

const posts: (Post & {
    author: (User & {
        posts: Post[];
    }) | null;
})[]

when removing orderBy it is correctly

const posts: (Post & {
    author: (User & {
        posts: (Post & {
            author: User | null;
        })[];
    }) | null;
})[]

Hi @AhmedElywa

Can you please give a minimal reproduction of this? Otherwise please share your datamodel and the client queries. It is quite time consuming to reproduce with screenshots as you can't copy code.

For what it’s worth, I had the same problem when in my schema.prisma file I had a Version model which clashed with some internal type also named “Version” but I couldn’t see the error in the console when compiling TypeScript because I had skipLibCheck set to true.

The lib error I got after disabling skipLibCheck was

node_modules/.pnpm/registry.npmjs.org/@prisma/client/[email protected]/node_modules/@prisma/client/index.d.ts:134:21 - error TS2300: Duplicate identifier 'Version'.

134 export declare type Version = {
                        ~~~~~~~

node_modules/.pnpm/registry.npmjs.org/@prisma/client/[email protected]/node_modules/@prisma/client/index.d.ts:1589:13 - error TS2300: Duplicate identifier 'Version'.

1589 export type Version = {
                 ~~~~~~~

Fixed in last beta

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pantharshit00 picture pantharshit00  Â·  4Comments

samrith-s picture samrith-s  Â·  3Comments

divyenduz picture divyenduz  Â·  3Comments

janpio picture janpio  Â·  4Comments

williamluke4 picture williamluke4  Â·  3Comments