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

HotChocolate.Data Filters and Sorting don't support explicit operations on a field level #3434

Closed
barticus opened this issue Apr 5, 2021 · 2 comments
Labels
Area: Data Issue is related to filtering, sorting, pagination or projections 🎉 enhancement New feature or request 🌶️ hot chocolate ⌛ stale Nothing happened with this issue in quite a while
Milestone

Comments

@barticus
Copy link

barticus commented Apr 5, 2021

Is your feature request related to a problem? Please describe.
In 11.1, there are a number of obsolete warnings for using the HotChocolate.Types.Filters and HotChocolate.Types.Sorting namespace, that suggest moving to the new HotChocolate.Data namespace.
The previous versions allowed a fluent-style syntax to explicitly set which filters/sorting operations to allow, but the new namespace allows all supported types by default.
E.g. this was the previous syntax allowed for this:

descriptor.Filter(t => t.Amount)
                .BindFiltersExplicitly()
                .AllowGreaterThanOrEquals()
                .And().AllowLowerThanOrEquals();

which is not supported.
As Pascal has let me know, this can be worked around by creating a ComparableOperationFilterInputType for each type that includes the filters that you want, but for porting mid-large projects, this will be quite a large task to move from 10.x to 11.x

Describe the solution you'd like
Support for a fluent type syntax on a per-field level would be great.
This could be the same structure ported over from 10.x, or from the examples Pascal sent, maybe it is easier to do this:

descriptor.Field(t => t.Amount)
                .AddOperation(DefaultFilterOperations.GreaterThanOrEquals)
                .MakeNullable();
descriptor.Field(t => t.Amount)
                .AddOperation(DefaultFilterOperations.LowerThanOrEquals)
                .MakeNullable();
descriptor.AllowAnd(false).AllowOr(false);

Describe alternatives you've considered

  • Opening up the fields to "all filters" instead of binding explicitly
  • Creating ComparableOperationFilterInputType per operation set i want to allow

Additional context
I appreciate all the work the team has put in!

@tobias-tengler tobias-tengler added the Area: Data Issue is related to filtering, sorting, pagination or projections label Jun 26, 2021
@michaelstaib michaelstaib added this to the Backlog milestone Nov 22, 2021
@stale
Copy link

stale bot commented May 4, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the ⌛ stale Nothing happened with this issue in quite a while label May 4, 2022
@stale stale bot closed this as completed May 11, 2022
@PascalSenn
Copy link
Member

@barticus This is comming in 13. It's already implemented and merged :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Data Issue is related to filtering, sorting, pagination or projections 🎉 enhancement New feature or request 🌶️ hot chocolate ⌛ stale Nothing happened with this issue in quite a while
Projects
None yet
Development

No branches or pull requests

4 participants