nestjs / nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
https://nestjs.com
MIT License
67.69k stars 7.63k forks source link

Mapped-types from @nestjs/graphql is not generating metadata using PluginMetadataGenerator #12197

Closed hari1602 closed 1 year ago

hari1602 commented 1 year ago

Is there an existing issue for this?

Current behavior

The extended types using PartialType from @nestjs/graphql is not generating the metadata. Since I'm using the swc-loader & monorepo structure, I'm following this step https://docs.nestjs.com/recipes/swc#monorepo. Is there anything I'm missing?

Minimum reproduction code

https://stackblitz.com/edit/nestjs-typescript-starter-pbexxs

Steps to reproduce

  1. npm i
  2. npx ts-node apps/repo/src/generate-metadata.ts
  3. The generated file can be found at this path apps/repo/src/metadata.ts
  4. The extended types for RepoUpdateInput from the metadata.ts file are missing

Expected behavior

  1. The generated file (apps/repo/src/metadata.ts) should have the extended types using PartialType.
  2. One example is RepoUpdateInput is extending the type from RepoCreateInput partially.
  3. Expecting the RepoUpdateInput from the metadata.ts file should have the extended types.

Package

Other package

@nestjs/graphql

NestJS version

10.0.3

Packages versions

{
  "name": "test",
  "version": "0.0.1",
  "private": true,
  "license": "UNLICENSED",
  "scripts": {
    "prebuild": "rimraf dist",
    "build": "nest build",
    "format": "prettier --write \"apps/**/*.ts\" \"libs/**/*.ts\"",
    "start": "nest start",
    "start:dev": "NODE_ENV=development nest start --watch",
    "start:debug": "nest start --debug --watch",
    "start:prod": "node dist/apps/gateway/main",
    "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
    "test": "jest",
    "test:watch": "jest --watch",
    "test:cov": "jest --coverage",
    "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
    "test:e2e": "jest --config ./apps/gateway/test/jest-e2e.json"
  },
  "dependencies": {
    "@apollo/gateway": "^2.4.8",
    "@apollo/server": "^4.7.4",
    "@apollo/subgraph": "^2.4.8",
    "@nestjs/apollo": "^12.0.3",
    "@nestjs/bull": "^10.0.0",
    "@nestjs/common": "^10.0.3",
    "@nestjs/config": "^3.0.0",
    "@nestjs/core": "^10.0.3",
    "@nestjs/cqrs": "^10.0.1",
    "@nestjs/graphql": "^12.0.8",
    "@nestjs/jwt": "^10.1.0",
    "@nestjs/mapped-types": "^2.0.2",
    "@nestjs/microservices": "^10.0.3",
    "@nestjs/passport": "^10.0.0",
    "@nestjs/platform-express": "^10.0.3",
    "@nestjs/swagger": "^7.0.4",
    "@nestjs/typeorm": "^10.0.0",
    "bull": "^4.10.4",
    "change-case": "^4.1.2",
    "class-transformer": "^0.5.1",
    "class-validator": "^0.14.0",
    "dotenv": "^16.3.1",
    "graphql": "^16.7.1",
    "graphql-type-json": "^0.3.2",
    "handlebars": "^4.7.7",
    "ioredis": "^5.3.2",
    "joi": "^17.9.2",
    "jwks-rsa": "^3.0.1",
    "lodash": "^4.17.21",
    "lower-case": "^2.0.2",
    "passport": "^0.6.0",
    "passport-jwt": "^4.0.1",
    "pg": "^8.11.0",
    "redis": "^4.6.7",
    "reflect-metadata": "^0.1.13",
    "rxjs": "^7.8.1",
    "title-case": "^3.0.3",
    "typeorm": "^0.3.17",
    "typeorm-extension": "^2.8.1",
    "typeorm-naming-strategies": "^4.1.0",
    "upper-case": "^2.0.2"
  },
  "devDependencies": {
    "@faker-js/faker": "^8.0.2",
    "@nestjs/cli": "^10.0.3",
    "@nestjs/schematics": "^10.0.1",
    "@nestjs/testing": "^10.0.3",
    "@types/express": "^4.17.17",
    "@types/graphql-type-json": "^0.3.2",
    "@types/jest": "29.5.2",
    "@types/lodash": "^4.14.195",
    "@types/node": "20.3.1",
    "@types/passport-jwt": "^3.0.8",
    "@types/source-map-support": "^0.5.6",
    "@types/supertest": "^2.0.12",
    "@typescript-eslint/eslint-plugin": "^5.60.0",
    "@typescript-eslint/parser": "^5.60.0",
    "commitizen": "^4.3.0",
    "cz-conventional-changelog": "^3.3.0",
    "eslint": "^8.43.0",
    "eslint-config-prettier": "^8.8.0",
    "eslint-plugin-prettier": "^4.2.1",
    "husky": "^8.0.3",
    "jest": "29.5.0",
    "lint-staged": "^13.2.2",
    "prettier": "^2.8.8",
    "source-map-support": "^0.5.21",
    "supertest": "^6.3.3",
    "swc-loader": "^0.2.3",
    "ts-jest": "29.1.0",
    "ts-loader": "^9.4.3",
    "ts-node": "^10.9.1",
    "tsconfig-paths": "4.2.0",
    "typeorm-seeding": "^1.6.1",
    "typescript": "^5.1.3",
    "webpack": "^5.88.0"
  },
}

Node.js version

19.9.0

In which operating systems have you tested?

Other

No response

kamilmysliwiec commented 1 year ago

Expecting the RepoUpdateInput from the metadata.ts file should have the extended types.

RepoUpdateInput class has only 1 attribute - id, which should be reflected in the metadata.ts file.

This output:

image

Is perfectly fine.