Prisma-client-js: Prisma Client is not consistently generating API for nested inserts

Created on 2 Jan 2020  Â·  7Comments  Â·  Source: prisma/prisma-client-js

Hi there,

We have run into a roadblock! We think that the generated photon api is inconsistently generated in relation to nested inserts.

Here is the photon type for creating a RoundPlatonic

image

If we look closer at roundUserPlatonics, we see that it is correct. I have highlighted the bit in question: WithoutRoundPlatonic...
image

If we look closer at levelRoundPlatonics, we see that it is incorrect. I have highlighted the bit that is wrong WithoutLevelPlatonic. We strongly feel that this should read WithoutRoundPlatonic (ie, he same as the previous pic.)
image

We are encountering this exact problem with other models as well.

Here is the prisma model:

image

Thank you so much for looking into this!! :)

bu0-needs-info kinbug statuneeds-action

Most helpful comment

Hey,

I'm sorry for not replying. I can't address this right now.

Urgently building COVID-19-related app.

Best wishes.

On Sun 15 Mar 2020, 3:58 p.m. Jan Piotrowski, notifications@github.com
wrote:

Ping @LydiaF https://github.com/LydiaF

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/prisma/prisma-client-js/issues/375#issuecomment-599228697,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ACMJTYIM4N42ATTAO66354LRHT3JZANCNFSM4KCNXEVQ
.

All 7 comments

We've encountered this too.

In our case this causes an activity with a nested create for it's lessons to error because it expects activityInput. But since it's nested in the create for an activity it's not possbile to provide it with the id of the activity since that one doesn't exist yet.

@LydiaF Can you please paste your whole datamodel here? I can't guess the other parts of it and you have pasted a screenshot here so I can't copy it easily.

@pantharshit00 Hey, thanks for your reply.

So, today we upgraded to the latest prisma and there were huge differences between the generated types. Long story short, now it all looks good but we have yet to properly test it. Hopefully this was the cause of the problem we were having. We will write back here next week and let you know if all went well.

Example:

model User {
  id    String @id @default(cuid())
  posts Post[] @relation(name: "UserPosts")
}

model Post {
  id     String @id @default(cuid())
  author User   @relation(name: "UserPosts")
}
// "@prisma/photon": "^2.0.0-preview019" and "prisma2": "^2.0.0-preview019" results in:
export declare type UserCreateInput = {
    id?: string | null;
    posts?: PostCreateManyWithoutPostsInput | null; // note "posts"
};

// "@prisma/client": "2.0.0-preview20.3" and "prisma2": "2.0.0-preview20.3" results in:
export declare type UserCreateInput = {
    id?: string | null;
    posts?: PostCreateManyWithoutAuthorInput | null; // note "author"
};

@LydiaF Please let me know if you get any trouble with this. If this is fixed already, then also feel free to close this issue.

Ping @LydiaF

Hey,

I'm sorry for not replying. I can't address this right now.

Urgently building COVID-19-related app.

Best wishes.

On Sun 15 Mar 2020, 3:58 p.m. Jan Piotrowski, notifications@github.com
wrote:

Ping @LydiaF https://github.com/LydiaF

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/prisma/prisma-client-js/issues/375#issuecomment-599228697,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ACMJTYIM4N42ATTAO66354LRHT3JZANCNFSM4KCNXEVQ
.

Closing due to inactivity. Please open a new issue in https://github.com/prisma/prisma if need to follow up.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

julien1619 picture julien1619  Â·  3Comments

MichalLytek picture MichalLytek  Â·  3Comments

williamluke4 picture williamluke4  Â·  3Comments

Errorname picture Errorname  Â·  3Comments

divyenduz picture divyenduz  Â·  3Comments