Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:pathom/as doesn't work with batched resolvers #89

Closed
rschmukler opened this issue Apr 15, 2019 · 2 comments
Closed

:pathom/as doesn't work with batched resolvers #89

rschmukler opened this issue Apr 15, 2019 · 2 comments

Comments

@rschmukler
Copy link
Contributor

It seems that using :pathom/as in conjunction with :pc/batch? true results in only the first item getting the alias applied, while all others are resolved with the original key.

@rschmukler
Copy link
Contributor Author

rschmukler commented May 22, 2019

Just adding a minimum test case:

(pc/defresolver foo-resolver [env input]
  {::pc/input  #{}
   ::pc/output [{:foos [:foo-id]}]}
  {:foos (map #(hash-map :foo-id %) (range 10))})

(pc/defresolver param-resolver [env input]
  {::pc/input  #{:foo-id}
   ::pc/output [:n]
   ::pc/batch? true}
  (let [n (-> env p/params :n)]
    (mapv (constantly {:n n}) input)))

(def registry [foo-resolver param-resolver])

(def parser
  (p/parallel-parser
   {::p/env     {::p/reader               [p/map-reader
                                           pc/parallel-reader
                                           pc/open-ident-reader
                                           p/env-placeholder-reader]
                 ::p/placeholder-prefixes #{">"}}
    ::p/mutate  pc/mutate-async
    ::p/plugins [(pc/connect-plugin {::pc/register registry})
                 p/error-handler-plugin
                 p/request-cache-plugin
                 p/trace-plugin]}))

(<!! (parser {} `[{:foos [(:n {:pathom/as :a :n 5})]}])))

Yielding:

{:foos [{:a 5} {:n 5} {:n 5} {:n 5} {:n 5} {:n 5} {:n 5} {:n 5} {:n 5} {:n 5}]}

@wilkerlucio
Copy link
Owner

Fixed in 70d2281

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants