After upgrading to Prisma 1.2.0, update mutations started breaking for me. On looking into prisma.graphql, I noticed that this is how update mutation input type is being generated,
input BlogUpdateInput {
where: BlogWhereUniqueInput!
data: BlogUpdateDataInput!
}
input ThemeUpdateDataInput {
title: String
user: UserUpdateInput
...
...
}
type mutations {
...
updateBlog(data: BlogUpdateInput!, where: BlogWhereUniqueInput!): Blog
}
Which means I would need to change update blog mutation calls to something like-
mutation {
updateBlog(data: {
data: {
title: "New Title"
},
where:{
id: "cjdlur7472ooe01549vgiyglm"
}
}, where: {
id: "cjdlur7472ooe01549vgiyglm"
}) {
id
title
user {
username
firstName
lastName
}
}
}
Are update mutation input types expected to be this way or is this a bug with 1.2.0 update?
This is related: #1902 - I was under the impression it is 1.3-beta exclusive. This is obviously not the case 🙂
Thanks for reporting @raeesaa
Hey @raeesaa thanks for reporting this. This is an unintended regression. I think this has to do with optional backrelations. Could you and @akoenig please check whether your schema make use of this feature? We're gonna fix this as soon as possible, but it would be good to know if you have this issue without having a relation with only one relation field.
@do4gr I can confirm that these changes are being reflected in schema as well but mutation fails if nested data property is passed.
I have the same issue, my update mutations broke after upgrading... :(
@do4gr Thanks for taking care of this regression 👍 I can also confirm that these changes are being reflected in the schema.
I can confirm that the fix from @do4gr resolved this issue! Thanks a lot! 🎉
@do4gr / @akoenig Are these changes published to npm? The latest version of Prisma is 1.2.3 which has this issue.
They are available in prisma@beta which uses the 1.3-beta-9 Docker image.
Hi, im still getting the same issues when using the beta channel. Would you please reinvestigate the issue? Thanks!
One question, can you double check that _the schema shown in the Playground_ is incorrect?
Because this might be an issue with your local version of the schema instead.
So in my case the db schema looks good in playground.
Updating to latest beta fixed issue for me as well.
On Feb 17, 2018 12:02 AM, "André König" notifications@github.com wrote:
So in my case the db schema looks good in playground.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/graphcool/prisma/issues/1909#issuecomment-366320049,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AER22TgeP9GiytQHzdSRkjSvwEovJWvBks5tVcmsgaJpZM4SGkcM
.
How do you check the schema in playground? Or do you just mean the config pointing to the right schema file? Im trying to check, but prisma deploy gets stuck at
Hooks:
Checking, if schema file changed... ⡿
ill get back as soon as I resolved this.
Using the beta channel, I now get the following weird behavior:
const res = await ctx.db.mutation.updateWall({
where: { id: wallId },
data: {
where: { id: wallId },
data:{
posts: {
create: {
text,
author: {
connect:
{
id: userId
},
}
}
}
}
}
}, `{
id
posts{
id
}
}`)
This mutation with the nested data/where objects does not throw the error as before. However, even though there is no error, the createPost is not executed, as I can not find a post afterwards.
The nested data/where objects are certainly not intended, are they? Or is this how prisma update mutations are supposed to look in the future?
It would be great to get feedback soon, this has been holding up my development for 2 days now, as all my update mutations are broken. Also, I am not sure if I simply should temporarily downgrade to an older prisma version, or if I should refactor my update mutations? Are there any leads on fixing this issue?
I talked to @akoenig and now I understand what is happening.
The reason why you might still encounter the problem after upgrading is that your local version of the schema is not updated.
Follow these steps to get back into a consistent state:
npm install -g prisma@beta graphql-cli
prisma local upgrade
graphql get-schema -p database -o src/generated/prisma.graphql
graphql prepare -p database -o src/generated
Note that the last step generates src/generated/database.{ts, graphql} instead of src/generated/prisma.{ts, graphql} (or js, respectively, if you're using the javascript generator), so depending on your .graphqlconfig.yml you might need to adjust the file names afterwards. I created an issue for this here: https://github.com/graphql-cli/graphql-cli/issues/211
@moritzmorgenroth If that _doesn't_ get you back in a consistent state, you are likely encountering one or more other issues. Please create a new issue report that explains your situation in its entirety, preferably with a reproducible example.
@marktani Thanks for you detailed response, I will follow the steps and hopefully it will resolve my issue. If not, I will break it up further and post reproducable code. The further I dig in, the more I have the feeling that you are right in assuming I am facing a combination of more than one issues. My problem seems to be somehow related to the create: argument in my mutations, which doesn't produce an error, but also doesn't create the object I am trying to create... Ill dig deeper and create an new issue if I cant resolve this with the update. Thanks everyone!
@marktani Finally back to a consistent state. You above solution indeed solved my issues, it was an issue with a local, orphaned schema file and repeatedly failing regeneration. Thanks a million!!! Maybe it might be nice to create a prisma cli command that regenerates the schema files cleanly in the above fassion.
You're welcome! 🙌
I created this feature request, which in my opinion will already help a lot: https://github.com/graphcool/prisma/issues/1927
I like your suggestion as well, feel free to create a different feature request, or comment on mine 🙂
Most helpful comment
I talked to @akoenig and now I understand what is happening.
The reason why you might still encounter the problem after upgrading is that your local version of the schema is not updated.
Follow these steps to get back into a consistent state:
Note that the last step generates
src/generated/database.{ts, graphql}instead ofsrc/generated/prisma.{ts, graphql}(orjs, respectively, if you're using the javascript generator), so depending on your.graphqlconfig.ymlyou might need to adjust the file names afterwards. I created an issue for this here: https://github.com/graphql-cli/graphql-cli/issues/211@moritzmorgenroth If that _doesn't_ get you back in a consistent state, you are likely encountering one or more other issues. Please create a new issue report that explains your situation in its entirety, preferably with a reproducible example.