Peter Kellner
06/28/2021, 4:21 PM"Cannot read property 'profile' of undefined",
I notice that the profile adding instructions are the same for all the other examples (or at least for the Profile add). My question is: "Does anyone of completed code that works for adding a Profile, and specifically the first mutation in the example?
After debugging some, the code in the mutation that seems to be problematic is here in the line context.prisma.profile.create
t.field("addProfileForUser", {
type: "Profile",
args: {
email: stringArg(),
bio: stringArg(),
},
resolve: async (_, args, context) => {
return context.prisma.profile.create({
data: {
bio: args.bio,
user: {
connect: {
email: args.email || undefined,
},
},
},
});
},
mutation {
addProfileForUser(
userUniqueInput: {
email: "<mailto:mahmoud@prisma.io|mahmoud@prisma.io>"
}
bio: "I like turtles"
) {
id
bio
user {
id
name
}
}
}
Ryan
06/29/2021, 5:18 AMuser
as well. Are you returning that someplace else?Peter Kellner
06/29/2021, 5:55 PMcontext.prisma.profile.create
but instead just prisma.profile.create
. I had thought prisma was showing undefined because of a debugger weirdness, but turns out, it really was undefined. As this example also uses getInitialProps inside _app.js,it’s and HOC’s instead of hooks for the apollo client, it really needs an overhaul. I asked about it this morning in the Prisma day / nextjs talk and the response I got was “I don’t really like Apollo, use swr instead”. ArgRyan
06/30/2021, 6:43 AMprisma
in your context undefined
? Could you share the code where you have passed the context?
Yeah I would suggest looking at my example. You would just need to replace Mercurius with Apollo