Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing modules after update #1621

Closed
jhmen opened this issue Jul 9, 2021 · 8 comments
Closed

Missing modules after update #1621

jhmen opened this issue Jul 9, 2021 · 8 comments

Comments

@jhmen
Copy link

jhmen commented Jul 9, 2021

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When I update NestJS to the newest version, the @nestjs/graphql can't find some modules during build.
image

Expected behavior

The project should build.

Minimal reproduction of the problem with instructions

  1. Create new NestJS project
  2. Update packages to the newest version
  3. Install GraphQL packages @nestjs/graphql graphql-tools graphql apollo-server-express
  4. Import the GraphQL module
  5. run yarn build

Environment


Nest version: 8.0.0

 
For Tooling issues:
- Node version: v14.17.0
- Platform:  Linux and Windows 
@natesilva
Copy link

The missing modules are ts-morph and @apollo/gateway. That was in the screenshot. I'm adding this comment to make it searchable.

I worked around this by adding the modules as dependencies in my project. I'd prefer not to have these "sub-dependencies" referenced in package.json.

@kamilmysliwiec
Copy link
Member

kamilmysliwiec commented Jul 12, 2021

That's actually something that we've been struggling with for a while already.

Both packages (ts-morph and @apollo/gateway) are optional. For example, if you're building a code-first GraphQL application (not federated), neither library is technically required. A different example would be if you had a code-first GQL Federated API, in this case, you need the @apollo/gateway library, but you'd never really interact with the ts-morph.

In the past, both libraries were included (auto-installed) by default as they were specified as "optionalDependencies". Now, they are registered as optional "peerDependencies" so their behavior will differ depending on what NPM version (NPM v7 automatically installs peer deps) you use/tsconfig settings you have. We made that change (moved these packages to the peerDependencies section) because ts-morph is quite a heavy package (since it's a compiler wrapper), not needed for all code first GraphQL apps.

Solutions:
a) manually install both deps (npm i ts-morph @apollo/gateway)
b) OR disable lib types checking in your tsconfig.json file (compilerOptions.skipLibCheck set to true) - this is the default value for new Nest projects as well

greatSumini added a commit to DEV-MUGLES/pickk-server that referenced this issue Jul 12, 2021
greatSumini added a commit to DEV-MUGLES/pickk-server that referenced this issue Jul 12, 2021
greatSumini added a commit to DEV-MUGLES/pickk-server that referenced this issue Jul 12, 2021
greatSumini added a commit to DEV-MUGLES/pickk-server that referenced this issue Jul 12, 2021
greatSumini added a commit to DEV-MUGLES/pickk-server that referenced this issue Jul 12, 2021
greatSumini added a commit to DEV-MUGLES/pickk-server that referenced this issue Jul 12, 2021
@DaniSchenk
Copy link

For those (like me) getting errors like

UnhandledPromiseRejectionWarning: Error: You must `await server.start()` before calling `server.apply Middleware()`

when using "apollo-server-express": "^3.0.0", there's already a fix #1627 on the way 🙌

@natesilva
Copy link

Thank you. I was able to get things working by setting compilerOptions.skipLibCheck to true (not false, I believe that was a typo).

My tsconfig.json was created under Nest 7.x and didn't have skipLibCheck set so that was why I was seeing the error.

greatSumini added a commit to DEV-MUGLES/pickk-server that referenced this issue Jul 13, 2021
greatSumini added a commit to DEV-MUGLES/pickk-server that referenced this issue Jul 13, 2021
* refactor(application): ♻️ add AbstractOrderSheetBuilder

* build: set tsconfig.skipLibCheck:true

- ref: nestjs/graphql#1621 (comment)

* feat(application): ✨ add OrderSheetsResolver.createOrderSheet

* chore: 🚨 apply prettier
resolve #76
@kamilmysliwiec
Copy link
Member

@DaniSchenk nestjs/nest#7543 (comment)

@iwt-twirth
Copy link

My solution is neither a) nor b), I prefer to c) explicitly declare the few missing types over skipping library type checks alltogether, on the other hand I did not run in any import issues with ts-morph so far.

// src/graphql-gateway-type-shim.d.ts

declare module '@apollo/gateway' {
    export interface GatewayConfig { }
    export interface ServiceEndpointDefinition { }
}

declare module '@apollo/gateway/dist/datasources/types' {
    export interface GraphQLDataSource { }
}

@sarancruzer
Copy link

nestjs/nest#7543 (comment)

jrhender added a commit to energywebfoundation/ssi-hub that referenced this issue Aug 10, 2021
Instead skipLibCheck can be added to tsconfig.json (which is the nestjs default)
nestjs/graphql#1621 (comment)
knzeng-e added a commit to energywebfoundation/ssi-hub that referenced this issue Aug 12, 2021
* feat: upgrade nest.js to v8

* feat: upgrade modules

* add package-lock.json

* fix(logger.service): add setContext

* chore: remove ts-morph as it is not necessary.

Instead skipLibCheck can be added to tsconfig.json (which is the nestjs default)
nestjs/graphql#1621 (comment)

* test(did.service, ens.service): fix Logger import

Logger import should match the import in the service

* feat(controllers): setting version neutral routes to prepare versioning

* feat(HttpModule): installed and use nestjs/axios to targuet the depreciated HttpModule


Co-authored-by: knzeng-e <[email protected]>
@benderTheCrime
Copy link

benderTheCrime commented Aug 22, 2021

Just in case there's an "issue behind an issue" here for GraphQLFederationModule user, during a 7.x -> 8.x upgrade I added skipLibCheck, and removed @apollo/gateway and ts-morph and I needed to install @apollo/federation:

{"level":50,"time":1629668486749,"pid":1,"hostname":"84bc3c814d24","msg":"The \"@apollo/federation\" package is missing. Please, make sure to install this library ($ npm install @apollo/federation) to take advantage of ApolloFederation."}

sgarner added a commit to equalogic/nestjs-graphql-connection that referenced this issue Sep 3, 2021
sgarner added a commit to equalogic/nestjs-graphql-connection that referenced this issue Sep 3, 2021
@nestjs nestjs locked and limited conversation to collaborators Sep 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants