Closed israelglar closed 5 years ago
Oops, I think I used path.sep
specifically because I thought thats what was supposed to be used for Windows 😬
Let me know if it's fixed in 0.9.13
That didn't fixed it :/ Maybe it's not that line, sorry. I'm trying to find where it is but with no luck.
That file and import statement is generated when the makePrismaSchema
function runs.
This is my function parameters:
const schema = makePrismaSchema({
// Provide all the GraphQL types we've implemented
types: [Query,Mutation,...typesList],
// Configure the interface to Prisma
prisma: {
client: prisma,
datamodelInfo: nexusPrismaSchema
},
// Specify where Nexus should put the generated files
outputs: {
schema: path.join(__dirname, './generated/schema.graphql'),
typegen: path.join(__dirname, './generated/nexus.ts'),
},
// Configure nullability of input arguments: All arguments are non-nullable by default
nonNullDefaults: {
input: false,
output: false,
},
// Configure automatic type resolution for the TS representations of the associated types
typegenAutoConfig: {
sources: [
{
source: path.join(__dirname, './interfaces/context.ts'),
alias: 'types',
},
],
contextType: 'types.Context',
},
});
The problem is here:
typegenAutoConfig: {
sources: [
{
source: path.join(__dirname, './interfaces/context.ts'),
alias: 'types',
},
],
contextType: 'types.Context',
},
The result on src/generated/nexus.ts
has this import with the backslashes:
import * as types from "..\interfaces\context"
And what is the error you get?
When node is trying to parse the string, it assumes the backslash is escape character, so what I get is:
src/generated/nexus.ts(6,24): error TS2307: Cannot find module '..interfacescontext'.
I don't have that issue with my linux machine
Ah thanks, that makes more sense. Just need to add escaping for the \
. I assume a JSON.stringify of the path will fix this. Will report back once it's fixed.
These lines generate the imports of the typegenAutoConfig. https://github.com/prisma/nexus/blob/18a306ee2903d98fc110c1067e1903ea0ee5f256/src/typegenAutoConfig.ts#L212-L215 And use this function https://github.com/prisma/nexus/blob/18a306ee2903d98fc110c1067e1903ea0ee5f256/src/typegenAutoConfig.ts#L340-L350
The problem is with this line:
In Windows it generates an import statement with backslashes
\
, and when node tries to compile it, it can't.Maybe change it to: