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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Bug Report: incorrect data type used for many-to-many relation on REST API controller #2224

Closed
yuval-hazaz opened this issue Jan 27, 2022 · 0 comments 路 Fixed by #2254
Assignees
Milestone

Comments

@yuval-hazaz
Copy link
Member

yuval-hazaz commented Jan 27, 2022

What happened?

The data type used in the generated app for many-to-many relations on the REST API controller is incorrect

 @common.UseInterceptors(nestMorgan.MorganInterceptor("combined"))
  @common.UseGuards(
    defaultAuthGuard.DefaultAuthGuard,
    nestAccessControl.ACGuard
  )
  @common.Patch("/:id/tags")
  @nestAccessControl.UseRoles({
    resource: "Post",
    action: "update",
    possession: "any",
  })
  async updateTags(
    @common.Param() params: PostWhereUniqueInput,
    @common.Body() body: PostWhereUniqueInput[],
    @nestAccessControl.UserRoles() userRoles: string[]
  ): Promise<void> {

In this example, when we update tags of a post, the body should be of type TagWhereUniqueInput and not PostWhereUniqueInput

    @common.Body() body: TagWhereUniqueInput[],

What you expected to happen

Fix the generated app to use the correct data type

How to reproduce

see above

Amplication version

0.11.1

Environment

n/a

Anything else

This bug does not have any actual impact on the API, since the type anyway include only a single property which is the same for all types

class PostWhereUniqueInput {
  @ApiProperty({
    required: true,
    type: String,
  })
  @IsString()
  @Field(() => String)
  id!: string;
}

Are you willing to submit PR?

No response

Code of Conduct

I agree to follow this project's Code of Conduct

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

Successfully merging a pull request may close this issue.

3 participants