Prisma-client-js: No more *GetSelectPayload exported by the client

Created on 12 Mar 2020  路  3Comments  路  Source: prisma/prisma-client-js

Hey,

Before installing @prisma/[email protected] and [email protected], I used to get a <Collection>GetSelectPayload for every model.

I used to use it to annotate the arguments to my functions like so:

function checkUserTroup(user: UserGetSelectPayload<{ troups: true }>): boolean {
    return !!user.troups.length;
}

Now, @prisma/client doesn't have any export called UserGetSelectPayload. So I tried this approach:

function checkUserTroup(user: UserGetPayload<UserArgs['select']['troups']>): boolean {
    return !!user.troups.length;
}

But this doesn't work and I get the following errors, which are fairly understandable:
image

My question is, is there any replacement for *GetSelectPayload?

kindocs kinquestion

Most helpful comment

Hey @samrith-s, thanks for opening this issue. I just updated the docs. This is how the new type UserGetPayload can be used:

import { UserGetPayload } from "@prisma/client";

// Define a type that includes the relation to `Post`
type UserWithPosts = UserGetPayload<{ 
  include: { posts: true } 
}>

// Define a type that only contains a subset of the scalar fields
type UserPersonalData = UserGetPayload<{
  select: { email: true; name: true }
}>

All 3 comments

Thank you for creating this issue 馃憤

So indeed UserGetSelectPayload was exported before and documented here but disappeared after the dynamic client changes by @timsuchanek

Now there is indeed UserGetPayload

I don't know any replacement or workaround yet, @timsuchanek will be the best person for that but he's on holiday at the moment. We'll get back as soon as possible 馃槂

Hey @samrith-s, thanks for opening this issue. I just updated the docs. This is how the new type UserGetPayload can be used:

import { UserGetPayload } from "@prisma/client";

// Define a type that includes the relation to `Post`
type UserWithPosts = UserGetPayload<{ 
  include: { posts: true } 
}>

// Define a type that only contains a subset of the scalar fields
type UserPersonalData = UserGetPayload<{
  select: { email: true; name: true }
}>

Gotcha, thanks! 馃槃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

julien1619 picture julien1619  路  3Comments

divyenduz picture divyenduz  路  4Comments

esistgut picture esistgut  路  4Comments

williamluke4 picture williamluke4  路  3Comments

macrozone picture macrozone  路  4Comments