-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Local typing error when running nexus build #1352
Comments
Can you show the part of app.ts please? (You can remove the parts you don't want to show) |
Sure: import { server, settings, use } from 'nexus'
import { prisma } from 'nexus-plugin-prisma'
import { PrismaClient } from '@prisma/client'
// ...
server.express.use((req, res, next) => {
req.prisma = new PrismaClient()
next()
}) Right now my workaround for completing the build is commenting line 78 of node_modules/nexus/dist/lib/tsc.js: if (allDiagnostics.length > 0) {
console.log(project.formatDiagnosticsWithColorAndContext(allDiagnostics));
// throw new Error(project.formatDiagnosticsWithColorAndContext(allDiagnostics));
} |
According to the tutorial you should either just do use(prisma()) to make prisma available in the context (as const db = new PrismaClient();
use(
prisma({
client: {
instance: db,
},
features: {
crud: true, // only if you want that
},
})
); if you need to do customizations. |
@mohe2015 Thanks, but this issue is not about Prisma usage, but a bug report regarding TypeScript typechecking done by |
@scleriot I know but the error schema.addToContext(async ({req, res}) => {
return {
db: new PrismaClient(), // If you really want to create a new one for every request
userId: getItSomehow(req)
};
}); |
Actually I'm trying no extend not only NexusContext type but also Express I should be able to extend any typings, in types/ directory for example as explained here: https://nexusjs.org/guides/project-layout#local-package-typings. Works well with |
Description
When building with
nexus build
I get typing error that I don't get when runningnexus dev
:Local typing is defined in:
express/index.d.ts looks like this:
Here is the corresponding tsconfig.json:
Nexus Report
I get the following error when doing nexus report:
The text was updated successfully, but these errors were encountered: