fix: resolve NewType subtype_of matching for filter args#412
Merged
zachdaniel merged 1 commit intoash-project:mainfrom Mar 5, 2026
Merged
Conversation
a179e03 to
a8a8749
Compare
There was a problem hiding this comment.
Pull request overview
Fixes GraphQL filter schema generation so fields typed with Ash.Type.NewType can match predicate operator/function argument type specs based on their subtype_of base type (e.g. allowing [:string, :string] predicates on NewType-backed string fields).
Changes:
- Update
do_get_expressable_types/3to consider a NewType’ssubtype_ofbase type when matching operator/function arg type signatures. - Add a regression test and supporting test fixtures (custom predicate function, resource, and ETS data layer wrapper) to ensure NewType subtype matching includes the expected predicate.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
lib/resource/resource.ex |
Extends expressable-type matching logic to consider NewType base type and tweaks warning string whitespace. |
test/filter_sort_test.exs |
Adds regression coverage asserting ilike appears for a NewType-backed filter field. |
test/support/test_ilike_function.ex |
Introduces a custom predicate function :ilike with [:string, :string] args for matching coverage. |
test/support/resources/tag_with_ilike.ex |
Adds a resource with a NewType attribute and restricted filter operators including :ilike. |
test/support/ets_with_functions.ex |
Adds an ETS-based data layer wrapper that exposes the custom function for tests. |
test/support/domain.ex |
Registers the new test resource in the test domain. |
💡 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
do_get_expressable_typesto checkAsh.Type.NewType.subtype_of/1base type when matching operator args, so operators expecting concrete types (e.g.[:string, :string]) work on NewType fieldsProblem
When a field uses a NewType (e.g.
subtype_of: :string), the GraphQL filter schema generation failed to match it against operator/function args like[:string, :string]. This caused predicate functions (e.g.Like) to be silently excluded from the generated filter input types, even when explicitly allowed viafilterable_fields.Solution
do_get_expressable_typesnow checksAsh.Type.NewType.subtype_of/1to resolve the base type's short name when matching against operator args. For example, a NewType withsubtype_of: :stringwill now also match operators that expect:stringin their args.