Error when using Photon to create new item with 2 relation connections
See original GitHub issueTo give a bit of background, this is my data model (or at least part of it):
model User {
// Meta
id String @default(cuid()) @id @unique
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
// Data
auth0Id String @unique
email String @unique
firstName String
lastName String
picture String
private Boolean @default(false)
userChallenges UserChallenge[] @relation(onDelete: CASCADE)
following Following[] @relation(name: "UserFollowing", onDelete: CASCADE)
followedBy Following[] @relation(name: "UserFollowed", onDelete: CASCADE)
comments Comment[] @relation(onDelete: CASCADE)
likes Like[] @relation(onDelete: CASCADE)
tags Tag[] @relation(onDelete: CASCADE)
challenging Challenging[] @relation(name: "UserChallenging", onDelete: CASCADE)
challengedBy Challenging[] @relation(name: "UserChallenged", onDelete: CASCADE)
reports Flag[] @relation(onDelete: NONE)
}
model Update {
// Meta
id String @default(cuid()) @id @unique
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
// Data
text String
type UpdateType
secret String @unique
userChallenge UserChallenge @relation(onDelete: NONE)
comments Comment[] @relation(onDelete: CASCADE)
likes Like[] @relation(onDelete: CASCADE)
tags Tag[] @relation(onDelete: CASCADE)
}
model Like {
// Meta
id String @default(cuid()) @id @unique
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
// Data
user User @relation(onDelete: NONE)
update Update @relation(onDelete: NONE)
}
The resolver I have trouble with is the one where I am trying to create a like:
export const likeMutations = extendType({
type: 'Mutation',
definition(t) {
t.field('createLike', {
type: 'Like',
args: { updateId: idArg({ required: true }) },
async resolve(parent, args, context) {
return context.photon.likes.create({
data: {
update: { connect: { id: args.updateId } },
user: { connect: { id: context.userId } },
},
});
},
});
},
});
Whenever I try to call that resolver with the right arguments, I get the following error:
I tried the same thing with creating a comment and I got the same error.
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
MonoBehaviourPunCallbacks ... - Photon Unity Networking 2
This callback is only called on the client which created a room (see OpCreateRoom). As any client might close (or drop connection) anytime,...
Read more >Connection Problems with Photon 2 in Unity - Info Gamer Hub
This problem is not caused by any errors. Instead, it is only due to both games connecting to different region servers.
Read more >[HELP] Photon Pun 2 Hashtable Error - Multiplayer - Unity Forum
Server: 'ns.exitgames.com' ErrorCode: 10054 SocketErrorCode: ConnectionReset Message: An existing connection was forcibly closed by the remote ...
Read more >Connection Problems with PUN 2 in Unity - YouTube
For this video, I will explain how to fix the problem in Photon where your editor and your standalone create new rooms instead...
Read more >Spring boot JPA OneToMany relationship - create related ...
I found the fix. Remove cascade attribute for Job member variable of Person Entity. JPA is combining both and also reusing the existing...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Fixed with: https://github.com/prisma/prisma/commit/b0df6842459f018a2178867ec728399cfcf47b25
The fix is available in a few minutes on
alpha
.Just FYI: The bug had nothing to do with relations. The problem were the fields
createdAt
andupdatedAt
in this case. The arguments for the scalar fields increateLike
were empty. We had a line that was not setting the default values for those fields in this case. Then the insert failed because the columns have to be not null.I had to do the migration again as well, it works now, though I found another bug. But this can be closed!