fix: Bool/ID/Int/Float/Decimal filter lookups without type parameter - #933
Open
skocks wants to merge 1 commit into
Open
fix: Bool/ID/Int/Float/Decimal filter lookups without type parameter#933skocks wants to merge 1 commit into
skocks wants to merge 1 commit into
Conversation
BoolFilterLookup, IDFilterLookup, IntFilterLookup, FloatFilterLookup and DecimalFilterLookup were resolved via the generic BaseFilterLookup/ ComparisonFilterLookup, re-specializing the generic per usage site for every filterable bool/ID/int/float/Decimal field across every model. For large schemas this is a meaningful share of build time (strawberry-graphql#519). Made them concrete, mirroring the StrFilterLookup/DateFilterLookup/ TimeFilterLookup/DatetimeFilterLookup fix from strawberry-graphql#891/strawberry-graphql#910 - completing that pattern for every remaining generic entry in type_filter_map. Breaking change: generated GraphQL input names lose their type prefix (e.g. IntComparisonFilterLookup becomes IntFilterLookup). Bumping as minor for this reason, matching strawberry-graphql#910's precedent.
skocks
marked this pull request as draft
July 6, 2026 12:21
Member
|
Thanks for adding the Below is the changelog that will be used for the release.
@strawberry_django.filter_type(models.Project)
class ProjectFilter:
is_active: strawberry_django.BoolFilterLookup | None
id: strawberry_django.IDFilterLookup | None
priority: strawberry_django.IntFilterLookup | None
weight: strawberry_django.FloatFilterLookup | None
budget: strawberry_django.DecimalFilterLookup | NoneMigrating:
Building on many models with many filterable fields previously re-specialized these |
skocks
marked this pull request as ready for review
August 3, 2026 05:39
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #519.
BoolFilterLookup,IDFilterLookup,IntFilterLookup,FloatFilterLookupandDecimalFilterLookupwere resolved via the genericBaseFilterLookup/ComparisonFilterLookup, re-specializing the generic at every usage site — once per filterable bool/ID/int/float/Decimal field, per model. For schemas with many models this adds up (#519's report: startup time scaling ~linearly with filter field count).Made them concrete, mirroring the
StrFilterLookup/DateFilterLookup/TimeFilterLookup/DatetimeFilterLookupfix from #891/#910 — this completes that same treatment for every remaining generic entry intype_filter_map. No changes needed toresolve_model_field_type's auto-resolution path; the__parameters__guard added in #910 already skips subscripting any concrete lookup generically.Breaking change
Generated GraphQL input names lose their type prefix:
IntComparisonFilterLookupbecomesIntFilterLookup,BoolBaseFilterLookupbecomesBoolFilterLookup,IDBaseFilterLookupbecomesIDFilterLookup. Clients referencing these inputs by name need to update. Bumping asminor, matching #910's precedent.Measured impact
Benchmarked cold schema builds on a real-world downstream schema (~180 models, 2 distinct exposure shapes), 3 runs each, before/after:
The marginal win on top of #910 alone is modest for this particular schema (datetime fields dominated its filter-lookup redundancy, and #910 already covers those) — but schemas with a larger share of bool/int/float/Decimal filterable fields relative to datetime fields should see comparatively more benefit, since this closes the same gap for those types.
Test plan
test_{str,date,time,datetime}_filter_lookup_without_type_parameterfor the 5 new concrete lookupstest_filter_type(auto-resolvedid/sweetnessfields now reportIDFilterLookup/IntFilterLookupinstead ofBaseFilterLookup/ComparisonFilterLookup)RELEASE.mdaddedSummary by Sourcery
Make scalar filter lookup inputs concrete for bool, ID, int, float, and Decimal fields to avoid per-field generic specialization and improve schema build performance.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Tests: