pathom

2023-08-23T18:53:30.060919Z

I think I found a weird bug related to reordering of collections that are nested inputs to a resolver:

(ns pathom-reverse-inputs
  (:require [com.wsscode.pathom3.connect.indexes :as pci]
            [com.wsscode.pathom3.connect.operation :as pco]
            [com.wsscode.pathom3.interface.eql :as p.eql]))
=> nil
(pco/defresolver reverse-inputs
  [input]
  {::pco/input [{:a [:b]}]}
  {:input input})
=> #'pathom-reverse-inputs/reverse-inputs
(p.eql/process
  (pci/register reverse-inputs)
  {:a (list {:b 1} {:b 2})}
  [:input])
=> {:input {:a ({:b 2} {:b 1})}}
Am I correct in assuming this is unintentional? I'll write up an issue if so.

wilkerlucio 2023-08-23T18:56:14.330119Z

I remember having this kind of issue before, there is even a helper that checks and reverts the order in such cases, but it might got missed using it somewhere

wilkerlucio 2023-08-23T18:58:52.214519Z

because Pathom will reconstruct collections as part of the processing, and for lists to keep the order we need to reverse it at the end of the operation

wilkerlucio 2023-08-23T18:59:18.030759Z

situations where this happens: https://github.com/search?q=repo%3Awilkerlucio%2Fpathom3%20coll%2Fcoll-append-at-head%3F&type=code

wilkerlucio 2023-08-23T18:59:37.577659Z

I guess there is some case missing in terms of nested inputs

2023-08-23T19:04:13.963519Z

I can work around it for now, thanks for checking!

Björn Ebbinghaus 2023-08-23T19:25:16.447239Z

In Pathom2 there was a helper to sort the output. It was necessary for batch resolvers. https://blog.wsscode.com/pathom/v2/pathom/2.2.0/connect/resolvers.html#_aligning_results

wilkerlucio 2023-08-23T20:02:47.059339Z

@mroerni Pathom 3 has that too, but this is a different kind of problem, the result align is for batch when you need to ensure the output list has the same size and positions as the input list

wilkerlucio 2023-08-23T20:02:54.147629Z

but here pathom is just reversing the list order