Fork me on GitHub
#pathom
<
2020-04-26
>
sergey.shvets00:04:49

Hi! Fantastic library, thank you @wilkerlucio! I'm stuck with collections of items and proper output string for resolver. Let's say I have a collection of items that returns comments for videos. They all have author id. How do I make the ::pc/output structure so I can join in queries on author_id? [[:comment/id :comment/text :comment/author_id]] doesn't work.

wilkerlucio01:04:15

I imagine something like: ::pc/output [:comment/id :comment/text :comment/author-id]

wilkerlucio01:04:33

but then you need resolvers to traverse from :comment/author-id to its data

sergey.shvets01:04:15

Do I need a special indication that I return a collection of maps and not a single map?

wilkerlucio05:04:11

🎉 32
pathom 12
👍 4
sergey.shvets07:04:18

I got this error when trying to build an app with viz-connector: The required namespace "com.wsscode.async.processing" is not available, it was required by "com/wsscode/pathom/viz/ws_connector/impl/sente_cljs.cljs".

sergey.shvets07:04:41

There is a small typo in docs: https://take.ms/dJ8DK

sergey.shvets07:04:20

To solve problem above I had to manually add [com.wsscode/async "1.0.4"] to my shadow-cljs.edn.

sergey.shvets07:04:29

After that works like a charm! HUGE THANKS!

wilkerlucio08:04:26

thanks, fixed!

wilkerlucio08:04:56

also tip to foce async version, but I will make pathom use a more recent one as well, I guess its one conflicting on it: https://roamresearch.com/#/app/wsscode/page/fI5tcHpMk

folcon16:04:05

Is there a straightforward way to get a pathom resolver to call another one? (I’m using it from Fulcro if that helps?)

myguidingstar16:04:51

@folcon can you give an example?

folcon16:04:11

EG: I have a pathom resolver:

(pc/defresolver session-account-resolver [env _]
  {::pc/output [:account/name]}
  (let [session (get-session env)
        username (some-> session :account/name)]
    {:account/name username}))
Is there some way I can just:
{::pc/input  [:account/name]}
I’ve worked out that I can do this manually by doing:
(defmutation account-resolver [{:keys [parser] :as env} _] {} {:account/name (parser env [:account/name])})
Which gives me a manytomany channel, happy to work with this directly, but just wondering if there’s a helper function to do this? Or some other way to do this?

myguidingstar16:04:42

@folcon what is the input and output of the mutation account-resolver?

myguidingstar16:04:15

and how would you use it?

myguidingstar16:04:56

anyway, I don't find any problem with that approach of calling parser

folcon16:04:33

Well what I’d like to do is this:

(pc/defresolver account-resolver [env opts]
  {::pc/input   [:account/name]
   ::pc/output [:account/info]}
  {:account/info (get-account-info (:account/name opts))})

folcon16:04:04

And pathom works out, why yes I do know how to resolve :account/name, let me grab that and pass it in!

dvingo14:04:14

Was this not working? I have it working with a similar setup:

(pc/defresolver current-user-res [env _]
  {::pc/output [:app/current-user]}
  {:app/current-user (get-current-user env)})

;; pathom resolves the current user into the input params here

(pc/defresolver user-tasks-resolver [env {:keys [:app/current-user]}]
  {::pc/input  #{:app/current-user}
   ::pc/output [{:user/tasks [:task/id :task/description]}]}
  (pull [{:user/tasks [:task/id :task/description]}] current-user))
I don't think it's supported for mutations. for that i just invoke the helper (get-current-user) directly in the mutation.

folcon14:04:06

Hmm, I was predominantly using it in mutations, I’ll see if there’s a difference in how they’re run…

myguidingstar16:04:27

why is it a mutation?

folcon16:04:01

Sorry, that’s just me using it as an example, in this case it should be a resolver… But I’d like to be able to do it for mutations too =)…

folcon16:04:55

This sort of thing is also really useful for things that are behind auth, so I can check, does the resolver for a session return a value? Ok, then grab the connected data associated with that account…

folcon16:04:59

Checking =)…

folcon16:04:09

Not quite that, I’ve done that before. In this case I’m trying to get pathom to get data that it knows about, as it has a resolver for it without me having to manually add the code that gets it into the mutation/resolver… Perhaps I should just try manually calling the built in parser function =)… Thanks for the help @myguidingstar!

myguidingstar16:04:14

you're welcome

codonnell20:04:51

Another option could be to write a plug in that injects the necessary data into the environment so your resolver can pull it out from there. Don't know enough about your use case to know if that's viable.

folcon23:04:19

Not really, I’m finding the solution of using the parser inline is sufficient =)… I did find a reference in the chat log that what I wanted to do is called nested inputs, apparently it’s something that may be supported in future, but not at present…

👍 4