I am following the context example here: <https:/...
# orm-help
j
I am following the context example here: https://www.howtographql.com/graphql-js/5-connecting-server-and-database/ implemented with auth as follows: Server:
const server = new ApolloServer({
gateway,
subscriptions: false,
context: ({ req }) => {
const user = req.user || null;
console.log("Prisma: " + prisma);
return { prisma, user };
}
})
Resolver:
<session request returning user>
console.log("Resolver: " + context.prisma);
context.prisma.account.create({
data: {
email: email,
password: password
},
});
Output:
Prisma: [object NewPrismaClient]
Resolver: undefined
If I stringify the context, I get:
Resolver: {"user":null,"_extensionStack":{"extensions":[]},"_shield":{"cache":{}}}
the prisma context object is always undefined in the resolver, what I am not understanding here?
r
Hey @Joe ๐Ÿ‘‹ From the code that you have shared, it seems that you have setup the context correctly. Let me try and reproduce this on the tutorial and see if I face the same issue. Could you also trying by restarting the server, removing
node_modules
and reinstalling again to see if it works?
๐Ÿ’ฏ 1
๐Ÿ‘ 1
j
I did try - same result.
i can try and send a subset of the server to you, if that would help, i just canโ€™t post it online.