Skip to content

How to use QueryService within a database transaction? #806

Open
@thehappycoder

Description

@thehappycoder

How to use QueryService within a database transaction? In particular, with TypeORM.

@Mutation(() => EntityDTO)
  async updateOneEntity(
    @Args('input') input: UpdateOneEntityDTO,
  ): Promise<EntityDTO> {
    return await this.dbConnection.transaction(async manager => {
          // How do I make `this.service` use the `manager`?
          const entity =  await this.service.updateOne(
            input.id,
            input.update,
          )

          // TODO Make an API call

          return entity
    })
  }

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions