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

Allow ID type can be list on xxxxFilterParameter, For filter ID allow it to be filtered by Equals, Not equals,In,NotIn #1259

Closed
tianyingchun opened this issue Dec 7, 2021 · 3 comments

Comments

@tianyingchun
Copy link
Contributor

Is your feature request related to a problem? Please describe.

Allow ID type can be list on xxxxFilterParameter, For filter ID allow it to be filtered by Equals, Not equals,In,NotIn

in some case like below i have entity as follow code


  /**
   * https://typeorm.io/#/relations/joincolumn-options
   */
  @ManyToOne(() => LensProcessOption)
  lensProcessOption: LensProcessOption;

  /**
   * ID type 
   */
  @Column()
  lensProcessOptionId: ID;

  /** 
   * https://typeorm.io/#/relations/joincolumn-options
   */
  @ManyToOne(() => LensProcessTemplate)
  lensProcessTemplate: LensProcessTemplate;

  /**
   *  ID type 
   */
  @Column()
  lensProcessTemplateId: ID;

in service layer i have below code

 Promise<PaginatedList<LensProcessConfigItem>> {
    return this.listQueryBuilder
      .build(LensProcessConfigItem, options, {
        ctx,
        relations: ['lensProcessOption', 'lensProcessOption.translations', 'lensProcessTemplate'],
      })

the query Builder , options it support me query filter like

filter.lensProcessOptionId = {
          eq: String(lensProcessOptionId),
        };
      }

but in front end , if LensProcessConfigItemFilterParameter don't allow me using lensProcessOptionId i have to write below Query

extend type Query {
    "Query all lens process template config item list"
    lensProcessConfigItems(
// manually add it as parameter
      lensProcessTemplateId: ID
// manually add it as parameter
      lensProcessOptionId: ID
      options: LensProcessConfigItemListOptions
    ): LensProcessConfigItemList!

manually add

 lensProcessTemplateId: ID
  lensProcessOptionId: ID

in fact if the options (LensProcessConfigItemListOptions) can list ID type as listOption, i can avoid this duplicated works

Describe the solution you'd like

Allow ID type can be list on XXX FilterParameter, For a filter on ID, it would make sense to allow it to be filtered by:
Equals
Not equals
In
Not in

Additional context
vendure@ v1.4.0-beta.0

@Draykee
Copy link
Contributor

Draykee commented Dec 7, 2021

To be honest I don't quite get what you need. I don't get why you have both lensProcessOption and lensProcessOptionId. I think you can just use @JoinColumn() to indicate that the you want the id (foreign key) to be on this side of the relation.

Do you want "smarter" generated FilterOptions for paginated lists?

@tianyingchun
Copy link
Contributor Author

use @joincolumn() and have both lensProcessOption and lensProcessOptionId is because i query this entity avoid using relation join.

@tianyingchun
Copy link
Contributor Author

tianyingchun commented Dec 7, 2021

because it can be auto list on graphql xxxxFilterParameter( lensProcessOptionId if type is number or string) in the front, i don't need wirte duplicated Query parameter to do this. but in some case i don't want to defined lensProcessOptionId as number or string type, i want to defined type as ID

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

No branches or pull requests

3 participants