feat: include builtin predicate functions in GraphQL filter schema#413
Merged
zachdaniel merged 1 commit intoash-project:mainfrom Mar 5, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a gap in the GraphQL filter schema generation: Ash.Filter.builtin_functions() (which returns predicate functions like Contains and IsNil) was not being included alongside Ash.Filter.builtin_operators() when building filter input types. As a result, functions like contains never appeared in generated filter schemas.
Changes:
- Added
Ash.Filter.builtin_functions()to the operator sources used infilter_type/3(for attributes/aggregates) andcalculation_filter_inputs/2(for calculations) inresource.ex - Updated the
VerifyFilterableFieldsverifier to also accept builtin function names as valid operator entries infilterable_fields - Added a regression test asserting
containsappears in theTagFilterNameinput type for a string field
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
lib/resource/resource.ex |
Adds builtin_functions() to the predicate sources for both attribute/aggregate and calculation filter type generation; also removes trailing whitespace in an unrelated warning string |
lib/resource/verifiers/verify_filterable_fields.ex |
Includes builtin_functions() in the set of valid operator names during compile-time validation of filterable_fields |
test/filter_sort_test.exs |
Adds an assertion that contains appears in the generated TagFilterName filter input type |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
zachdaniel
approved these changes
Mar 5, 2026
Contributor
|
🚀 Thank you for your contribution! 🚀 |
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.
Contributor checklist
Leave anything that you believe does not apply unchecked.
Summary
Ash.Filter.builtin_functions()alongsidebuiltin_operators()in filter type generation for both attributes and calculationsfilterable_fieldsverifier to also recognize builtin function names (e.g.:contains) as valid operator entriesProblem
Ash.Filter.builtin_functions()returns predicate functions likeContainsandIsNil, but they were not included in the GraphQL filter schema generation pipeline. OnlyAsh.Filter.builtin_operators()andAsh.DataLayer.functions()were used, so functions likecontainsnever appeared in filter input types.Breaking change
This adds new filter input fields (e.g.
contains) to all string/applicable filter types by default. Existing users whose clients rely on strict schema validation may see unexpected fields.To restrict filters to the previous set, use
filterable_fieldswith explicit operator allowlists: