question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New issue with makeSchema (getTypeMap of undefined)

See original GitHub issue

I honestly have no clue where this issue began. Yesterday, at some point, I started getting this error on yarn generate:

yarn run v1.22.5
warning package.json: No license field
$ npm -s run generate:prisma && npm -s run generate:nexus
Environment variables loaded from prisma/.env
Prisma Schema loaded from prisma/schema.prisma

✔ Generated Prisma Client (version: 2.7.0) to ./../../node_modules/@prisma/client in 216ms

You can now start using Prisma Client in your code:

import { PrismaClient } from '@prisma/client'
// or const { PrismaClient } = require('@prisma/client')

const prisma = new PrismaClient()

Explore the full API: http://pris.ly/d/client
TypeError: Cannot read property 'getTypeMap' of undefined
    at generateMiddlewareFromSchemaAndRuleTree (/home/zaneh/Desktop/redacted/node_modules/graphql-shield/src/generator.ts:241:28)
    at MiddlewareGenerator.generator (/home/zaneh/Desktop/redacted/node_modules/graphql-shield/src/generator.ts:293:5)
    at MiddlewareGenerator.generate (/home/zaneh/Desktop/redacted/node_modules/graphql-middleware/src/generator.ts:19:17)
    at middlewares.map.middleware (/home/zaneh/Desktop/redacted/node_modules/graphql-middleware/src/middleware.ts:72:25)
    at Array.map (<anonymous>)
    at applyMiddlewareWithOptions (/home/zaneh/Desktop/redacted/node_modules/graphql-middleware/src/middleware.ts:70:45)
    at applyMiddleware (/home/zaneh/Desktop/redacted/node_modules/graphql-middleware/src/middleware.ts:129:10)
    at new GraphQLServer (/home/zaneh/Desktop/redacted/node_modules/graphql-yoga/src/index.ts:137:13)
    at Object.<anonymous> (/home/zaneh/Desktop/redacted/packages/backend/src/server.ts:28:16)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I can’t think of anything that would’ve caused this, but I tried rolling back to a previous (and known-to-work) commit, deleting my node_modules, and reinstalling, but I never got it back to a working state 🥳. If anyone has any info/debugging tips for this, I’m all ears

My package.json:

{
  "name": "@redacted/backend",
  "version": "1.0.0",
  "scripts": {
    "generate": "npm -s run generate:prisma && npm -s run generate:nexus",
    "generate:prisma": "prisma generate",
    "generate:nexus": "ts-node --transpile-only src/schema",
    "dev": "ts-node-dev --no-notify --respawn --transpileOnly src/server",
    "codegen": "graphql-codegen --config codegen.yml",
    "seed": "ts-node prisma/seed.ts"
  },
  "dependencies": {
    "@nexus/schema": "0.16.0",
    "@paypal/checkout-server-sdk": "^1.0.2",
    "@prisma/client": "2.7.0",
    "@sendgrid/mail": "^7.2.6",
    "aws-sdk": "^2.743.0",
    "bcryptjs": "^2.4.3",
    "cors": "^2.8.5",
    "cuid": "^2.1.8",
    "dotenv-flow": "^3.2.0",
    "graphql": "15.3.0",
    "graphql-iso-date": "^3.6.1",
    "graphql-middleware": "4.0.1",
    "graphql-shield": "7.3.6",
    "graphql-yoga": "1.18.3",
    "lodash": "^4.17.20",
    "multer": "^1.4.2",
    "nexus-plugin-prisma": "0.19.0",
    "sanitize-html": "^2.0.0"
  },
  "devDependencies": {
    "@graphql-codegen/cli": "^1.17.8",
    "@graphql-codegen/typescript": "^1.17.9",
    "@graphql-codegen/typescript-operations": "^1.17.8",
    "@graphql-codegen/typescript-react-apollo": "^2.0.6",
    "@prisma/cli": "2.7.0",
    "@types/aws-sdk": "^2.7.0",
    "@types/bcryptjs": "^2.4.2",
    "@types/cors": "^2.8.7",
    "@types/cuid": "^1.3.1",
    "@types/dotenv-flow": "^3.1.0",
    "@types/graphql-iso-date": "^3.4.0",
    "@types/multer": "^1.4.4",
    "@types/node": "12.12.54",
    "@types/sanitize-html": "^1.27.0",
    "@types/ws": "^7.2.7",
    "ts-node": "9.0.0",
    "ts-node-dev": "1.0.0-pre.50",
    "typescript": "4.0.3"
  }
}

I’ve tried:

  • Adding and removing the graphql package in package.json
  • console.log(schema) (no output or undefined)
  • Checking the permissions on my project files
  • Resetting my DB (and making sure the connection works)
  • Commenting out large sections of code
  • Using known-to-work package versions from the Prisma examples repo
  • Using a different machine
  • Removing my middleware altogether
  • Following: https://github.com/facebookarchive/relay-starter-kit/issues/58 (no dice)
  • Ensuring all of my types are included in the schema

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
hyochancommented, Aug 3, 2021

How did you fix this at the end? I got the same issue out of a sudden and couldn’t get things to work again, I tried different prisma clients from 2.9 up to lastest, please share your package.json if you can

Try not to import prisma from the context.ts. Pass it through the args. I had this problem earlier.

1reaction
ZaneHcommented, Oct 5, 2020
Old news

I’m making progress, but nothing is making sense yet:

yarn run v1.22.5
warning package.json: No license field
$ npm -s run generate:prisma && npm -s run generate:nexus
Environment variables loaded from prisma/.env
Prisma Schema loaded from prisma/schema.prisma

✔ Generated Prisma Client (version: 2.7.0) to ./../../node_modules/@prisma/client in 214ms

You can now start using Prisma Client in your code:

import { PrismaClient } from '@prisma/client'
// or const { PrismaClient } = require('@prisma/client')

const prisma = new PrismaClient()

Explore the full API: http://pris.ly/d/client
# My console.log (logs all of my included types, all of the ones after "index.ts" in the file directory are undefined...):
NexusObjectTypeDef {
  name: 'AuthPayload',
  config: { name: 'AuthPayload', definition: [Function: definition] } } NexusObjectTypeDef {
  name: 'File',
  config: { name: 'File', definition: [Function: definition] } } NexusObjectTypeDef {
  name: 'Image',
  config: { name: 'Image', definition: [Function: definition] } } undefined undefined undefined undefined undefined undefined undefined undefined undefined
Warning: Your GraphQL `File` object definition is projecting a field `product` with `Product` as output type, but `Product` is not defined in your GraphQL Schema

Warning: Your GraphQL `Image` object definition is projecting a field `product` with `Product` as output type, but `Product` is not defined in your GraphQL Schema

Error: 
- Missing type User, did you forget to import a type to the root query?
    at Object.assertNoMissingTypes (/home/zaneh/Desktop/redacted/node_modules/@nexus/schema/src/utils.ts:323:11)
    at Object.makeSchema (/home/zaneh/Desktop/redacted/node_modules/@nexus/schema/src/builder.ts:1524:3)
    at Object.<anonymous> (/home/zaneh/Desktop/redacted/packages/backend/src/server.ts:71:11)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Module.m._compile (/home/zaneh/Desktop/redacted/node_modules/ts-node/src/index.ts:1043:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Object.require.extensions.(anonymous function) [as .ts] (/home/zaneh/Desktop/redacted/node_modules/ts-node/src/index.ts:1046:12)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

So, I removed ./types/index.ts and things started working a little bit better. Now I’m only missing 1 type. It’s the Mutation type. However, I think the issue is rooted deeper than “The Mutation file” because in all of my types, the relational t.model.<other_model>() fields are error’ing.

In addition, I know the code in my type files is correct. It hasn’t been changed since my last working commit.

I’m going to pause here. If anyone can help, I’d appreciate it

Read more comments on GitHub >

github_iconTop Results From Across the Web

New issue with makeSchema (getTypeMap of undefined) #523
I honestly have no clue where this issue began. Yesterday, at some point, I started getting this error on yarn generate: yarn run...
Read more >
makeSchema - GraphQL Nexus
makeSchema. Defines the GraphQL schema, by combining the GraphQL types defined by the GraphQL Nexus layer or any manually defined GraphQL named types ......
Read more >
Open Source Used In Socio 1.0 - Cisco
This document contains licenses and notices for open source software used in this product. With respect to the free/open source software listed in...
Read more >
Apollo makeExecutableSchema throws error "Cannot read ...
javascript - Apollo makeExecutableSchema throws error "Cannot read property 'kind' of undefined" - Stack Overflow. Stack Overflow for Teams – ...
Read more >
How to use the nexus.makeSchema function in nexus - Snyk
const schema = makeSchema({ types: schemaTypes, // All inputs are non nullable. // Remember, after release, every new input must be nullable. //...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found