absinthe_relay
absinthe_relay copied to clipboard
Problem with backward pagination using Connection.from_query
Fails trying Connection.from_query with args:
%{after: nil, before: "YXJyYXljb25uZWN0aW9uOjE=", first: nil, last: 10}
If I try instead with %{before: "YXJyYXljb25uZWN0aW9uOjE=", last: 10}
, it works.
Hi @susana-garcia can you elaborate on what "fails" means? Do you get an exception? Does it simply not work?
@benwilson512 thanks for the quick answer and sorry for the short description: I get this exception:
** (exit) an exception was raised:
** (ArithmeticError) bad argument in arithmetic expression
(absinthe_relay) lib/absinthe/relay/connection.ex:456: Absinthe.Relay.Connection.from_query/4
(absinthe) lib/absinthe/resolution.ex:209: Absinthe.Resolution.call/2
(absinthe) lib/absinthe/phase/document/execution/resolution.ex:209: Absinthe.Phase.Document.Execution.Resolution.reduce_resolution/1
(absinthe) lib/absinthe/phase/document/execution/resolution.ex:168: Absinthe.Phase.Document.Execution.Resolution.do_resolve_field/4
(absinthe) lib/absinthe/phase/document/execution/resolution.ex:153: Absinthe.Phase.Document.Execution.Resolution.do_resolve_fields/6
(absinthe) lib/absinthe/phase/document/execution/resolution.ex:72: Absinthe.Phase.Document.Execution.Resolution.walk_result/5
(absinthe) lib/absinthe/phase/document/execution/resolution.ex:53: Absinthe.Phase.Document.Execution.Resolution.perform_resolution/3
(absinthe) lib/absinthe/phase/document/execution/resolution.ex:24: Absinthe.Phase.Document.Execution.Resolution.resolve_current/3
(absinthe) lib/absinthe/pipeline.ex:274: Absinthe.Pipeline.run_phase/3
(absinthe_plug) lib/absinthe/plug.ex:421: Absinthe.Plug.run_query/4
(absinthe_plug) lib/absinthe/plug.ex:247: Absinthe.Plug.call/2
(phoenix) lib/phoenix/router/route.ex:40: Phoenix.Router.Route.call/2
(phoenix) lib/phoenix/router.ex:288: Phoenix.Router.__call__/2
(invest_api) lib/invest_api/endpoint.ex:1: Acrevis.InvestAPI.Endpoint.plug_builder_call/2
(invest_api) lib/plug/debugger.ex:122: Acrevis.InvestAPI.Endpoint."call (overridable 3)"/2
(invest_api) lib/invest_api/endpoint.ex:1: Acrevis.InvestAPI.Endpoint.call/2
(phoenix) lib/phoenix/endpoint/cowboy2_handler.ex:42: Phoenix.Endpoint.Cowboy2Handler.init/4
(cowboy) /Users/susu/joshmartinProjects/acrevis/backend/deps/cowboy/src/cowboy_handler.erl:41: :cowboy_handler.execute/2
(cowboy) /Users/susu/joshmartinProjects/acrevis/backend/deps/cowboy/src/cowboy_stream_h.erl:320: :cowboy_stream_h.execute/3
(cowboy) /Users/susu/joshmartinProjects/acrevis/backend/deps/cowboy/src/cowboy_stream_h.erl:302: :cowboy_stream_h.request_process/3
Please provide the output of the following: mix deps |grep absinthe
.
ᐅ mix deps | grep absinthe
* absinthe 1.4.16 (Hex package) (mix)
locked at 1.4.16 (absinthe) 0933e4d9
* absinthe_relay 1.4.6 (Hex package) (mix)
locked at 1.4.6 (absinthe_relay) ec0e2288
* absinthe_ecto 0.1.3 (Hex package) (mix)
locked at 0.1.3 (absinthe_ecto) 420b6812
* absinthe_error_payload 1.0.1 (Hex package) (mix)
locked at 1.0.1 (absinthe_error_payload) 06963145
* absinthe_plug 1.4.7 (Hex package) (mix)
locked at 1.4.7 (absinthe_plug) 939b6b9e
* absinthe_phoenix 1.4.4 (Hex package) (mix)
locked at 1.4.4 (absinthe_phoenix) af3b7b44
Yeah this line here https://github.com/absinthe-graphql/absinthe_relay/blob/master/lib/absinthe/relay/connection.ex#L528 should check for nil. I can push an update up but it'll come out as the 1.5 rc release since we're very close to releasing 1.5.
No rush, I made a workaround for now just deleting the nil values from the args. Thank you and Happy New Year!
@benwilson512 can I get any more insight into the timeline on this issue getting resolved? We just ran into this as well, but it's going to be kind of a pain to remove the nil values from args every where we use connections