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

_softDeletedAt filter do not spread for nested records #8

Open
SvaRgoS opened this issue Dec 29, 2023 · 3 comments
Open

_softDeletedAt filter do not spread for nested records #8

SvaRgoS opened this issue Dec 29, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@SvaRgoS
Copy link

SvaRgoS commented Dec 29, 2023

Bug report

Required System information

  • Node.js version:
  • NPM version:
  • Strapi version:
  • Database:
  • Operating system:
  • Is your project Javascript or Typescript:

Describe the bug

I run the following query


query Suppliers($filters: SupplierFiltersInput, $certificationsFilters2: CertificationFiltersInput) {
  suppliers(filters: $filters) {
    data {
      id
      attributes {
        companyName
        recipient_organization {
          data {
            id
            attributes {
              name
              certifications(filters: $certificationsFilters2) {
                data {
                  id
                }
              }
            }
          }
        }
      }
    }
  }
}

some of the Suppliers have a recipient_organization that have a few deleted certifications

And they appear in the results. Unfortunately.

I guess because


const sdWrapParams = async (defaultService: any, opts: any, ctx: { uid: string, action: string }) => {
  const { uid, action } = ctx;
  const wrappedParams = await defaultService.wrapParams(opts, ctx);

  if (!plugin.supportsContentType(uid)) {
    return wrappedParams;
  }

  // Prevent users to set values for _softDeletedAt, _softDeletedById, and _softDeletedByType
  if (wrappedParams.data) {
    delete wrappedParams.data._softDeletedAt;
    delete wrappedParams.data._softDeletedById;
    delete wrappedParams.data._softDeletedByType;
  }

  return {
    ...wrappedParams,
    filters: {
      $and: [
        {
          ...wrappedParams.filters
        },
        {
          _softDeletedAt: {
            $null: true
          },
        },
      ],
    },
  };
}

the following filter

     _softDeletedAt: {
            $null: true
          },
          

apply only for top level entity.

Steps to reproduce the behavior

  1. Create two or more entities
  2. add relations between they
  3. add records to both of the table
  4. remove some of nested records
  5. Make request with related nested records.

You will see deleted records in the result

Expected behavior

I think would be good to get only non-deleted records.

@SvaRgoS SvaRgoS added the bug Something isn't working label Dec 29, 2023
@cdreier
Copy link

cdreier commented Mar 13, 2024

we just stumpled across the same issue, did you find a good solution or workaround in the meantime? when trying to set _softDeletedAt in the query filter, it fails the gql validations

edit: same problem in the strapi ui, you still see all the soft-deleted entities in the linked fields

@SvaRgoS
Copy link
Author

SvaRgoS commented Mar 13, 2024

No, I don't have a solution at the moment :-( I'm going to remove the plugin from the project. That would be nice, but I don't need it right now.

@iantrudell
Copy link

Has anyone found a workaround or solution for this? We are unable to use this currently because we have so many populated relations that keep returning related collection entries that were soft deleted.

Example:
Collection: Category
Collection: Post

Category has many Posts

Delete a post (soft delete)

Get Category, populate all posts in that category - the populate still returns the soft deleted posts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants