TriPSs/nestjs-query

Extend nested filter input-types to allow filter-depth configuration per relation.

hedwiggggg opened this issue · 0 comments

Extend nested filter input-types (#143) to allow filter-depth configuration per relation.

@FilterableRelation('relation', () => Relation, {
  // This one does not work yet
  filterDepth: 2,
})

Describe the solution you'd like

Requires further customization in the /nestjs-query/packages/query-graphql/src/types/query/filter.type.ts file. At Object.keys(filterableRelations).forEach((field) => { the filterDepth of the relation should be considered (only if set), not the filterDepth of the parent element.

// Example-A.entity.ts
@ObjectType('EntityA')
@FilterableRelation('relation', () => relation)
class EntityA { /* ... */ }

// leads to
// input EntityAFilter {
//    # should generate depending on the `filterDepth` of `EntityA`
//    relation: EntityAFilterRelationFilter
// }
// Example-B.entity.ts
@ObjectType('EntityB')
@FilterableRelation('relation', () => relation, { filterDepth: 2 )
class EntityB { /* ... */ }

// leads to
// input EntityBFilter {
//     # should generate a filter type of depth 2
//     relation: EntityBFilterRelationFilter
// }

This is not a critical feature for me personally, so I will look at this in the future when I have more resources available again.