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

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

Open
2 of 4 tasks
NilsMoller opened this issue Aug 10, 2023 · 1 comment
Open
2 of 4 tasks

Comments

@NilsMoller
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

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;
}
  1. Update the user.model.ts:
@ObjectType()
export class User extends ModelBase {
  @Field()
  name: string;
}
  1. Start the projects (gateway last)
  2. 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?

  • macOS
  • Windows
  • Linux

Other

  • Tried with both federation 1 and 2.
  • I presume this is an issue not specifically related to federation, but I do not know enough about directives to test other configurations for now.
  • I have tested this with the (currently) latest versions in my own project with the same results:
"@apollo/server": "^4.9.1",
"@nestjs/apollo": "^12.0.7",
"@nestjs/graphql": "^12.0.8",
"graphql": "^16.7.1",
@NilsMoller NilsMoller changed the title @Directive on abstract ObjectType is not applied to inherited classes @Directive on abstract @ObjectType is not applied to inherited classes Aug 10, 2023
@kamilmysliwiec
Copy link
Member

Would you like to create a PR for this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants