Skip to content

Cannot read property 'getDirectives' of undefined at printFilteredSchema #10061

@sathyarajagopal

Description

@sathyarajagopal

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

I have downloaded the code at https://github.com/tkssharma/nodejs-graphql-world/tree/master/Graphql%20using%20Apollo/nestjs-graphql-code-first-%2302 and tried running it. During the NestJS server start, at GraphQL module load, I am getting the below error:
(node:6187) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'getDirectives' of undefined
at printFilteredSchema (/nodejs-graphql-world-master/Graphql using Apollo/nestjs-graphql-code-first-#02/node_modules/graphql/utilities/printSchema.js:54:27)
at printSchema (/nodejs-graphql-world-master/Graphql using Apollo/nestjs-graphql-code-first-#02/node_modules/graphql/utilities/printSchema.js:40:10)
at ApolloDriver.start (/nodejs-graphql-world-master/Graphql using Apollo/nestjs-graphql-code-first-#02/node_modules/@nestjs/apollo/dist/drivers/apollo.driver.js:21:85)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async GraphQLModule.onModuleInit (/nodejs-graphql-world-master/Graphql using Apollo/nestjs-graphql-code-first-#02/node_modules/@nestjs/graphql/dist/graphql.module.js:105:9)
at async callModuleInitHook (/nodejs-graphql-world-master/Graphql using Apollo/nestjs-graphql-code-first-#02/node_modules/@nestjs/core/hooks/on-module-init.hook.js:51:9)
at async NestApplication.callInitHook (/nodejs-graphql-world-master/Graphql using Apollo/nestjs-graphql-code-first-#02/node_modules/@nestjs/core/nest-application-context.js:178:13)
at async NestApplication.init (/nodejs-graphql-world-master/Graphql using Apollo/nestjs-graphql-code-first-#02/node_modules/@nestjs/core/nest-application.js:96:9)
at async NestApplication.listen (/nodejs-graphql-world-master/Graphql using Apollo/nestjs-graphql-code-first-#02/node_modules/@nestjs/core/nest-application.js:154:33)
at async bootstrap (/nodejs-graphql-world-master/Graphql using Apollo/nestjs-graphql-code-first-#02/src/main.ts:6:3)
(Use node --trace-warnings ... to show where the warning was created)
Graphql using Apollo/nestjs-graphql-code-first-#02/node_modules/@cspotcode/source-map-support/source-map-support.js:745
(node:6187) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
Graphql using Apollo/nestjs-graphql-code-first-#02/node_modules/@cspotcode/source-map-support/source-map-support.js:745
(node:6187) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

When I comment out the below code, the server starts:
// GraphQLModule.forRoot({
// driver: ApolloDriver,
// definitions: {
// path: join(process.cwd(), 'src/graphql.schema.ts'),
// outputAs: 'class'
// }
// })

Minimum reproduction code

https://github.com/tkssharma/nodejs-graphql-world/tree/master/Graphql%20using%20Apollo/nestjs-graphql-code-first-%2302

Steps to reproduce

npm i
npm run start

Expected behavior

NestJs server successfully started

Package

  • I don't know. Or some 3rd-party package
  • @nestjs/common
  • @nestjs/core
  • @nestjs/microservices
  • @nestjs/platform-express
  • @nestjs/platform-fastify
  • @nestjs/platform-socket.io
  • @nestjs/platform-ws
  • @nestjs/testing
  • @nestjs/websockets
  • Other (see below)

Other package

No response

NestJS version

9.0.8

Packages versions

    "@nestjs/apollo": "^10.0.19",
    "@nestjs/common": "^9.0.7",
    "@nestjs/config": "^2.2.0",
    "@nestjs/core": "^9.0.7",
    "@nestjs/graphql": "^10.0.21",
    "@nestjs/platform-express": "^9.0.7",
    "@nestjs/typeorm": "^9.0.0",
    "apollo-server-express": "^3.10.0",
    "graphql": "^15.8.0",
    "graphql-tool": "^1.0.0",
    "joi": "^17.6.0",
    "pg": "^8.7.3",
    "reflect-metadata": "^0.1.13",
    "rimraf": "^3.0.2",
    "rxjs": "^7.5.6",
    "ts-morph": "^15.1.0",
    "typeorm": "^0.3.7"

Node.js version

14.19.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageThis issue has not been looked into

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions