Error occurs when starting up prisma after having successfully applied a schema. No queries are made, the server does not even become available as this error occurs.
I'm not entirely sure how to resolve this issue, especially with us not being able to share the full schema, but it would be good to know how to debug this, or to find out what kind of schema setups would cause the "Cannot read property 'map' of undefined" error as right now it could be an actual bug, or an error in our schema, anywhere in the 4000+ lines of the schema.
package.json for prisma looks like this:
{
"name": "typescript-graphql",
"scripts": {
"start": "node dist/server",
"clean": "rm -rf dist",
"build": "npm -s run clean && npm -s run generate && tsc",
"generate": "npm -s run generate:prisma && npm -s run generate:nexus",
"generate:prisma": "prisma2 generate",
"generate:nexus": "ts-node --transpile-only src/schema",
"postinstall": "npm -s run generate",
"dev": "ts-node-dev --no-notify --respawn --transpileOnly src/server"
},
"dependencies": {
"@prisma/client": "latest",
"graphql": "14.6.0",
"graphql-yoga": "1.18.3",
"nexus": "0.12.0-rc.9",
"nexus-prisma": "0.7.0"
},
"devDependencies": {
"@prisma/sdk": "0.0.172",
"@types/node": "12.12.25",
"@types/ws": "6.0.4",
"prisma2": "latest",
"ts-node": "8.5.4",
"ts-node-dev": "1.0.0-pre.44",
"typescript": "3.7.5"
},
"prettier": {
"singleQuote": true,
"semi": false,
"trailingComma": "all"
},
"engines": {
"node": ">=10.0.0"
}
}
Our schema is over 4000 lines long and contains information about the business that I should not share.
It does though have a lot of relations like this:
model User {
id Int @id
createdAt DateTime @default(now())
email String @unique
name String?
role Role @default(USER)
posts Post[]
user1 User[] @relation("UserOne")
user2 User[] @relation("UserTwo")
}
model Post {
id Int @id
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
author User
title String
published Boolean @default(false)
}
enum Role {
USER
ADMIN
}
Migrating the database
prisma2 migrate up --experimental
Outputs the schema, time it took etc.
Can see the schema has been migrated successfully, tables, relations, indexes exist
Start Typescript prisma2 express server:
npm run dev
Ouput:
> typescript-graphql@ dev /app/prisma/typescript/graphql
> ts-node-dev --no-notify --respawn --transpileOnly src/server
Using ts-node version 8.5.4, typescript version 3.7.5
TypeError: Cannot read property 'map' of undefined
at Object.definition (/app/prisma/typescript/graphql/node_modules/nexus-prisma/src/publisher.ts:126:12)
at SchemaBuilder.walkInputType (/app/prisma/typescript/graphql/node_modules/nexus/src/builder.ts:1363:9)
at SchemaBuilder.walkTypes (/app/prisma/typescript/graphql/node_modules/nexus/src/builder.ts:678:16)
at SchemaBuilder.getFinalTypeMap (/app/prisma/typescript/graphql/node_modules/nexus/src/builder.ts:786:10)
at makeSchemaInternal (/app/prisma/typescript/graphql/node_modules/nexus/src/builder.ts:1583:15)
at Object.makeSchema (/app/prisma/typescript/graphql/node_modules/nexus/src/builder.ts:1628:49)
at Object.<anonymous> (/app/prisma/typescript/graphql/src/schema.ts:6:26)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Module._compile (/app/prisma/typescript/graphql/node_modules/source-map-support/source-map-support.js:541:25)
at Module.m._compile (/tmp/ts-node-dev-hook-6002760669962068.js:57:25)
[ERROR] 08:19:49 TypeError: Cannot read property 'map' of undefined
Adding DEBUG=* as environment variable did not provide more output.
Hey @86label try upgrading your nexus and nexus-prisma to the latest version. The versions you are using are not compatible with the latest prisma2 version AFAIK
Thanks, will definitely try! @BjoernRave
Issue was resolved after upgrading nexus and nexus-prisma from
"nexus": "0.12.0-rc.9",
"nexus-prisma": "0.7.0"
to
"nexus": "0.12.0-rc.13",
"nexus-prisma": "0.11.1"
Most helpful comment
Issue was resolved after upgrading nexus and nexus-prisma from
to