File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -187,4 +187,29 @@ defmodule AshGraphql.ResourceTest do
187187
188188 assert List . first ( data ) [ "rank" ] < List . last ( data ) [ "rank" ]
189189 end
190+
191+ test "can use argument in filter and sort on calculated field" do
192+ [
193+ "a" ,
194+ "b" ,
195+ "c"
196+ ]
197+ |> Enum . each ( fn text ->
198+ Ash.Seed . seed! ( % AshGraphql.Test.Comment { text: text } )
199+ end )
200+
201+ assert { :ok , % { data: % { "listComments" => data } } } =
202+ """
203+ query {
204+ listComments(
205+ filter: {timestampWithArg: {input: {seconds: 10}}}
206+ sort: {timestampWithArgInput: {seconds: 10}, field: TIMESTAMP_WITH_ARG, order: ASC_NULLS_LAST}
207+ ) {
208+ text
209+ timestampWithArg(seconds: 10)
210+ }
211+ }
212+ """
213+ |> Absinthe . run ( AshGraphql.Test.Schema )
214+ end
190215end
Original file line number Diff line number Diff line change @@ -75,6 +75,13 @@ defmodule AshGraphql.Test.Comment do
7575 expr ( created_at ) ,
7676 public?: true
7777 )
78+
79+ calculate :timestamp_with_arg ,
80+ :utc_datetime_usec ,
81+ expr ( created_at + fragment ( "make_interval(secs => ?)" , ^ arg ( :seconds ) ) ) do
82+ argument ( :seconds , :integer , allow_nil?: false )
83+ public? ( true )
84+ end
7885 end
7986
8087 relationships do
You can’t perform that action at this time.
0 commit comments