Skip to content
This repository has been archived by the owner on Jan 14, 2021. It is now read-only.

No more *GetSelectPayload exported by the client #564

Closed
samrith-s opened this issue Mar 12, 2020 · 3 comments
Closed

No more *GetSelectPayload exported by the client #564

samrith-s opened this issue Mar 12, 2020 · 3 comments
Assignees
Labels
kind/docs A documentation change is required. kind/question Developer asked a question. No code changes required.

Comments

@samrith-s
Copy link

Hey,

Before installing @prisma/client@2.0.0-alpha.904 and prisma2@2.0.0-alpha.904, 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?

@pantharshit00 pantharshit00 added the kind/question Developer asked a question. No code changes required. label Mar 18, 2020
@Jolg42 Jolg42 added kind/docs A documentation change is required. process/candidate Candidate for next Milestone. labels Mar 18, 2020
@Jolg42
Copy link
Member

Jolg42 commented Mar 18, 2020

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 😃

@nikolasburk
Copy link
Member

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 }
}>

@samrith-s
Copy link
Author

Gotcha, thanks! 😄

@janpio janpio removed the process/candidate Candidate for next Milestone. label Mar 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/docs A documentation change is required. kind/question Developer asked a question. No code changes required.
Projects
None yet
Development

No branches or pull requests

6 participants