t3 stack with trpc-openapi mongodb - getting error Cannot read properties of undefined (reading 'prisma')

747 views Asked by At

Beginner here trying out t3 stack app with trpc-openapi. Prisma provider is using mongodb. I can connect to MongoDB but when I make the call http://localhost:3000/api/all from http://localhost:3000/api-docs I get error

{
  "message": "Cannot read properties of undefined (reading 'prisma')",
  "code": "INTERNAL_SERVER_ERROR"
}

Source for the app is at https://github.com/firefoxNX/cosmic_monk.

I don't see any other error in the server console.

1

There are 1 answers

0
Vineet Bhatia On

I was not passing the context which holds the prisma client in multiple places where createOpenApiNextHandler was being used.

import {createTRPCContext} from "../../server/api/trpc";
...
return createOpenApiNextHandler({router: appRouter, createContext: createTRPCContext})(req, res);