Fork me on GitHub
#pathom
<
2020-10-11
>
yenda16:10:11

is there a way to specify the union-path with a defresolver? i.e I want to do the union query on the value of the :type key and not some specific keys in the map

yenda20:10:45

So if anyone is looking for a solution some day: my problem was that not only I have a union query based on the value of a specific key :notification/type, I also want to remove some of the results based on some of the values of some key (ie video/deleted?, user/blocked?) I also want pagination, which I do using the following output:

[:pagination/edges [{:follow [:notification/type
                                             :notification/timestamp
                                             :user/id]
                     :comment [:notification/type
                                              :notification/timestamp
                                              :comment/text
                                              :user/id
                                              :video/id
                                              :video/deleted?]...
   :pagination/has-prev?
   :pagination/has-next?
   :pagination/first-cursor
   :pagination/last-cursor]
so to achieve this I used 2 resolvers, one that outputs [{:notifications [:raw-notifications]}] and one that outputs the schema above the second resolver takes the raw-notifications as input and uses join-seq-parallel to resolve the raw notifications so that the resolver can filter on the values initially I wanted to use one resolver but for some reason I couldn't get join-seq-parallel to work, I would get
[{:pagination/first-cursor :com.wsscode.pathom.core/not-found, :pagination/has-next? :com.wsscode.pathom.core/not-found, :pagination/last-cursor :com.wsscode.pathom.core/not-found, :pagination/has-prev? :com.wsscode.pathom.core/not-found, :pagination/edges :com.wsscode.pathom.core/not-found} {:pagination/first-cursor :com.wsscode.pathom.core/not-found, :pagination/has-next? :com.wsscode.pathom.core/not-found, :pagination/last-cursor :com.wsscode.pathom.core/not-found, :pagination/has-prev? :com.wsscode.pathom.core/not-found, :pagination/edges :com.wsscode.pathom.core/not-found} {:pagination/first-cursor :com.wsscode.pathom.core/not-found, :pagination/has-next? :com.wsscode.pathom.core/not-found, :pagination/last-cursor :com.wsscode.pathom.core/not-found, :pagination/has-prev? :com.wsscode.pathom.core/not-found, :pagination/edges :com.wsscode.pathom.core/not-found}]

yenda20:10:00

another thing that bothers me is that I add to set the ::p/union-path globally

::p/union-path
                     (fn [env]
                       (let [e (p/entity env)]
                         (:notification/type e)))
I was hoping I could limit it to the resolver