pathom

:pathom: https://github.com/wilkerlucio/pathom/ & https://pathom3.wsscode.com & https://roamresearch.com/#/app/wsscode
markaddleman 2020-06-01T02:28:37.164800Z

My data is naturally hierarchical: events have attributes and attributes have attributeValues And the user walks that hierarchy in the UI by first select an event, then attribute and then an attribute value. It seems like I should be able to construct a pathom query like this

[{[:event "an event"] [{[:attribute "some attribute"] [:attributeValues]}]}]
But this resolver doesn't get invoked:
(pc/defresolver event-attribute-values [env input]
  {::pc/input  #{:event :attribute}
   ::pc/output [{:attributeValues [:attributeValue]}]}
  (println "event-attribute-values" input)
  {:attributeValues (into [] (select-keys-distinct [:attributeValue])
                          (es/list-result! [:attribute-values-v1] env input))})

markaddleman 2020-06-01T14:25:11.169100Z

Thanks but that doesn't work either because an ident is defined as a vector with two elements.

markaddleman 2020-06-01T14:25:43.169300Z

I did play around with a new reader that accepts a map as an ident instead of a two-element vector. It seems to work but I have more playing to do šŸ™‚

sergey.shvets 2020-06-01T19:40:34.169500Z

Pathom won't pass your :event attributes to the second join automatically. You need to do it manually. Just make sure that inside your :event resolver you pass down the :event property. You need to modify your event-attribute resolver to return :event that I assume it gets as an input.

sergey.shvets 2020-06-01T19:41:23.169800Z

I now do it for every "join" resolver and it allows me for pretty much unlimited nested joins

markaddleman 2020-06-01T19:43:37.170Z

Thanks for the insight. I'm pretty new to pathom - Can you give me an example of passing the event attribute to the second join?

markaddleman 2020-06-01T19:44:19.170200Z

Do you mean that it's the responsibility of the resolver?

markaddleman 2020-06-01T19:47:56.170400Z

I updated my resolver to pass along :event and now it works like I expect. Thanks!

sergey.shvets 2020-06-01T20:06:42.170600Z

Yes. I would vote for having this done by pathom, but for now it is responsibility of a resolver to do so.

markaddleman 2020-06-01T20:16:57.170800Z

Yeah, I agree with your vote šŸ™‚

markaddleman 2020-06-01T20:17:03.171Z

I ran into a related problem:

markaddleman 2020-06-01T20:18:21.171200Z

I have two resolvers one with output

[{:attributes [:attribute :attributeType :dataType :path :event]}]
and another with output
[{:attributes [:attribute :attributeType :dataType :path]}]
(the only difference is that one produces :event and the other doesnot

markaddleman 2020-06-01T20:19:12.171400Z

This reflects two different locations of :attributes in my graph: one set of attributes is global for the entire UI while the other set of attributes is event-specific

markaddleman 2020-06-01T20:20:13.171600Z

This query gets handled by the event-specific resolver:

{:events [:event {:attributes [:attribute :ui-location :dataType :path :attributeValues]}]}

markaddleman 2020-06-01T20:20:38.171800Z

But this one gets resolved by the global resolver:

{[:event "My Savings Coupon Edited"] [{:attributes [:attribute :ui-location :dataType :path :attributeValues]}]}

markaddleman 2020-06-01T20:21:28.172Z

The obvious solution is to have two separate attribute lists, :global-attributes and :event-attributes

sergey.shvets 2020-06-01T20:25:51.172200Z

yes, I think this is the best way to solve it. Alternatively, you can pass the proper resolver type as a param, but that is way more uglier, imo

markaddleman 2020-06-01T20:28:10.172400Z

I agree

markaddleman 2020-06-01T20:28:16.172600Z

Thanks for the pointers!

sergey.shvets 2020-06-01T20:38:48.172800Z

You welcome. I'm pretty new to pathom as well, but Wilker was super helpful and helped me solve the exact same problem couple of weeks ago

šŸ‘ 1
markaddleman 2020-06-01T02:30:16.164900Z

I read in the docs that I can provide a pathom/context map but that seems contrary to the idea of a graph query.

markaddleman 2020-06-01T02:56:29.165100Z

I think it's interesting that this query resolves:

[{[:event "Sign In Forgot Password Submitted"] [{:attributes [:attribute :path :attributeValues]}]}]

markaddleman 2020-06-01T02:57:07.165300Z

I expect that I could provide an ident in the place of :attributes

markaddleman 2020-06-01T02:57:14.165500Z

Am I thinking of pathom wrong?

2020-06-01T06:04:04.168300Z

Iā€™m not very skilled in Pathom but what happens if you put all the context together?:

[{[:event "an event"
   :attribute "some attribute"] [:attributeValues]}]