prisma / prisma-client-js

Type-safe database client for TypeScript & Node.js (ORM replacement)
Apache License 2.0
1.47k stars 67 forks source link

Adding orderBy to included field breaks typings #615

Closed malekjaroslav closed 4 years ago

malekjaroslav commented 4 years ago

Bug description

OrderBy in deeper include breaks types.

How to reproduce

  1. Use https://github.com/prisma/prisma-examples/tree/prisma2/typescript/graphql
  2. Add new queryField

    const test = queryField('test', {
    type: 'Boolean',
    resolve: async (self, args, { prisma }) => {
    const users = await prisma.user.findMany({
      include: {
        posts: {
          include: {
            author: true
          },
          orderBy: {
             title: "asc"
          },
        },
      },
    
    })
    // Here author is not available in typescript suggestion
    users.map(d => d.posts[0].author)
    },
    })

    Expected behaviour

    Author type should be available in the post

Prisma

Using Preview-24 but also fails on 2.0.0-alpha.972

pantharshit00 commented 4 years ago

I can confirm this bug in preview025 and in 2.0.0-alpha.997

timsuchanek commented 4 years ago

Thanks a lot for reporting 🙏 This issue is fixed in the latest alpha version of @prisma/cli. You can try it out with npm i -g @prisma/cli@alpha.

In case it’s not fixed for you - please let us know and we’ll reopen this issue!