nestjs / graphql

GraphQL (TypeScript) module for Nest framework (node.js) 🍷
https://docs.nestjs.com/graphql/quick-start
MIT License
1.46k stars 396 forks source link

`@Directive` on abstract `@ObjectType` is not applied to inherited classes #2960

Open NilsMoller opened 1 year ago

NilsMoller commented 1 year ago

Is there an existing issue for this?

Current behavior

Having a base @ObjectType({ isAbstract: true }) class decorated with @Directive('@key(fields: "id")') does not apply that directive to inherited classes.

Minimum reproduction code

N/A

Steps to reproduce

  1. Copy sample 31 for code-first federation.
  2. Add a model.base.ts to users-application/src/users/models:
    @ObjectType({
    isAbstract: true,
    })
    @Directive('@key(fields: "id")')
    export class ModelBase {
    @Field((type) => ID)
    id: number;
    }
  3. Update the user.model.ts:
    @ObjectType()
    export class User extends ModelBase {
    @Field()
    name: string;
    }
  4. Start the projects (gateway last)
  5. See the error in the gateway console

Expected behavior

The directive is applied to all inheriting classes.

Package version

12.0.8

Graphql version

"@apollo/gateway": "2.2.3",
"@apollo/server": "4.7.5",
"@nestjs/apollo": "12.0.3",
"@nestjs/graphql": "12.0.3",
"graphql": "16.6.0",
"graphql-tools": "9.0.0",

NestJS version

^10.0.3

Node.js version

18.17.0

In which operating systems have you tested?

Other

kamilmysliwiec commented 1 year ago

Would you like to create a PR for this issue?