Open Weakky opened 3 years ago
I use a lot of them and I found a few tricks to work with prisma:
typegenAutoConfig: {
backingTypeMap: {
DateTime: 'Date',
Email: 'string',
JSONObject: 'db.JsonObject',
},
contextType: 'ctx.Application',
sources: [
{
alias: 'ctx',
source: path.join(__dirname.replace(/\/dist$/, '/src'), './context/index.ts'),
},
{
alias: 'db',
source: '.prisma/client/index.d.ts',
},
{
alias: 'models',
source: path.join(__dirname.replace(/\/dist$/, '/src'), './models/index.ts'),
typeMatch: type => [new RegExp(`(${type.name})`)], // Note: This will match any declared type in models if the name matches
},
],
},
So any type that I export in models
automatically replaces the Prisma type.
I also added some type backing in https://github.com/graphql-nexus/schema/pull/473
Description
The current docs about backing types are still using the nexus framework API https://nexusjs.org/docs/guides/schema#backing-types-in-nexus
We should convert them to be using the nexus schema API and also potentially make it a top-level guide or something as it's something core to Nexus that's fairly hidden.
Related #509