Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions lib/resource/resource.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2626,8 +2626,12 @@ defmodule AshGraphql.Resource do
array_type? = match?({:array, _}, type)

fields =
Ash.Filter.builtin_operators()
|> Enum.concat(Ash.DataLayer.functions(resource))
[
Ash.Filter.builtin_operators(),
Ash.Filter.builtin_functions(),
Ash.DataLayer.functions(resource)
]
|> Enum.concat()
|> Enum.filter(& &1.predicate?())
|> restrict_for_lists(type)
|> restrict_for_field(resource, attribute_or_aggregate)
Expand Down Expand Up @@ -2920,8 +2924,12 @@ defmodule AshGraphql.Resource do
array_type? = match?({:array, _}, field_type)

filter_fields =
Ash.Filter.builtin_operators()
|> Enum.concat(Ash.DataLayer.functions(resource))
[
Ash.Filter.builtin_operators(),
Ash.Filter.builtin_functions(),
Ash.DataLayer.functions(resource)
]
|> Enum.concat()
|> Enum.filter(& &1.predicate?())
|> restrict_for_lists(field_type)
|> restrict_for_field(resource, calculation)
Expand Down Expand Up @@ -5027,8 +5035,8 @@ defmodule AshGraphql.Resource do
if Application.compile_env(:ash_graphql, :warn_on_json_fallback?, true) do
defp warn_on_json_fallback(resource, constraints) do
IO.warn("""
Struct type with instance_of constraint falls back to JsonString for input.
Consider creating a custom type with `use AshGraphql.Type` and `graphql_input_type/1`
Struct type with instance_of constraint falls back to JsonString for input.
Consider creating a custom type with `use AshGraphql.Type` and `graphql_input_type/1`
for structured validation.

Resource: #{inspect(resource)}
Expand Down
3 changes: 2 additions & 1 deletion lib/resource/verifiers/verify_filterable_fields.ex
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ defmodule AshGraphql.Resource.Verifiers.VerifyFilterableFields do
resource = Transformer.get_persisted(dsl, :module)

builtin =
Ash.Filter.builtin_operators()
[Ash.Filter.builtin_operators(), Ash.Filter.builtin_functions()]
|> Enum.concat()
|> Enum.filter(& &1.predicate?())
|> Enum.map(& &1.name())

Expand Down
1 change: 1 addition & 0 deletions test/filter_sort_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ defmodule AshGraphql.FilterSortTest do
assert "eq" in field_names
assert "lessThan" in field_names
assert "greaterThan" in field_names
assert "contains" in field_names
end

test "sortable_fields option is applied" do
Expand Down
Loading