nestjs-query icon indicating copy to clipboard operation
nestjs-query copied to clipboard

FilterableUnPagedRelation decorator not working with withDeleted: true

Open zilvis97 opened this issue 1 year ago • 3 comments

Describe the bug I have a File entity that is linked to FileToProject relation by the ID. I want to query potentially deleted Files (which works fine) along with the deleted nested FileToProject relation. However, when I use FilterableUnPagedRelation with withDeleted: true, it seems to have no effect on the query and I just get an empty toProjects array and it seems it is querying "toProjects"."deletedAt" IS NULL despite withDeleted being set.

Have you read the Contributing Guidelines?

yes

To Reproduce Check out this repo https://github.com/zilvis97/nestjs-filterableunpagedrelation-deleted-issue/

  1. Create a File object
mutation {
  createOneFile(
    input: { file: { id: "1", name: "File 1", deletedAt: null} }
  ) {
    id
    name
    deletedAt
  }
}
  1. Create FileToProject object that references previously created File
mutation {
  createOneFileToProject(
    input: { fileToProject: { projectID: "3", fileID: "1", type:"PHOTO", version:1, deletedAt: null } }
  ) {
    projectID
    fileID
    type
    deletedAt
  }
}
  1. Query files with linked toProjects object and you will be able to see the link
query {
  files {
    edges {
      node {
        id
        name
        deletedAt
        toProjects {
          projectID
          fileID
        }
      }
    }
  }
}
  1. Create another FileToProject that references the same File, but the deletedAt date for this object
mutation {
  createOneFileToProject(
    input: { fileToProject: { projectID: "3", fileID: "1", type:"PHOTO", version:1, deletedAt: "2024-09-09T00:00:00.000Z" } }
  ) {
    projectID
    fileID
    type
    deletedAt
  }
}
  1. Query files again and you will see that the latest relation will not be returned in the toProjects array

Expected behavior withDeleted: true option should be properly applied to FilterableUnPagedRelation

Screenshots

Screenshots of the data Files: image

FilesToProjects: image

As you can see there are 3 FileToProject links, but only the non deleted one is resolved on the File side.

Desktop (please complete the following information):

  • Node Version [e.g. 14.14.0]
  • Nestjs-query Version [e.g. v0.21.0]

Additional context Add any other context about the problem here.

zilvis97 avatar Sep 06 '24 10:09 zilvis97

Think the Nestjs versie seems incorrect? If not please update to the latest version, if the problem persists please create a repo that reproduces this issue.

TriPSs avatar Sep 06 '24 12:09 TriPSs

@TriPSs I upgraded the versions but that doesn't seem to have any affect, I updated the issue description and added a link to the repo to reproduce the issue.

zilvis97 avatar Sep 09 '24 12:09 zilvis97

After looking at the code it seems this is not implemented for the many.

TriPSs avatar Sep 09 '24 15:09 TriPSs