Skip to content

feat: include builtin predicate functions in GraphQL filter schema#413

Merged
zachdaniel merged 1 commit intoash-project:mainfrom
nallwhy:feat/include-builtin-functions-in-filters
Mar 5, 2026
Merged

feat: include builtin predicate functions in GraphQL filter schema#413
zachdaniel merged 1 commit intoash-project:mainfrom
nallwhy:feat/include-builtin-functions-in-filters

Conversation

@nallwhy
Copy link
Copy Markdown
Contributor

@nallwhy nallwhy commented Mar 4, 2026

Contributor checklist

Leave anything that you believe does not apply unchecked.

  • I accept the AI Policy, or AI was not used in the creation of this PR.
  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

Summary

  • Include Ash.Filter.builtin_functions() alongside builtin_operators() in filter type generation for both attributes and calculations
  • Update the filterable_fields verifier to also recognize builtin function names (e.g. :contains) as valid operator entries

Problem

Ash.Filter.builtin_functions() returns predicate functions like Contains and IsNil, but they were not included in the GraphQL filter schema generation pipeline. Only Ash.Filter.builtin_operators() and Ash.DataLayer.functions() were used, so functions like contains never 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_fields with explicit operator allowlists:

filterable_fields [:name, email: [:eq, :in, :less_than, :greater_than]]

Copilot AI review requested due to automatic review settings March 4, 2026 13:54
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 in filter_type/3 (for attributes/aggregates) and calculation_filter_inputs/2 (for calculations) in resource.ex
  • Updated the VerifyFilterableFields verifier to also accept builtin function names as valid operator entries in filterable_fields
  • Added a regression test asserting contains appears in the TagFilterName input 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 zachdaniel merged commit 15d4036 into ash-project:main Mar 5, 2026
25 of 27 checks passed
@zachdaniel
Copy link
Copy Markdown
Contributor

🚀 Thank you for your contribution! 🚀

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

Successfully merging this pull request may close these issues.

3 participants