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))})
Thanks but that doesn't work either because an ident is defined as a vector with two elements.
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 š
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.
I now do it for every "join" resolver and it allows me for pretty much unlimited nested joins
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?
Do you mean that it's the responsibility of the resolver?
I updated my resolver to pass along :event
and now it works like I expect. Thanks!
Yes. I would vote for having this done by pathom, but for now it is responsibility of a resolver to do so.
Yeah, I agree with your vote š
I ran into a related problem:
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 doesnotThis 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
This query gets handled by the event-specific resolver:
{:events [:event {:attributes [:attribute :ui-location :dataType :path :attributeValues]}]}
But this one gets resolved by the global resolver:
{[:event "My Savings Coupon Edited"] [{:attributes [:attribute :ui-location :dataType :path :attributeValues]}]}
The obvious solution is to have two separate attribute lists, :global-attributes
and :event-attributes
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
I agree
Thanks for the pointers!
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
I read in the docs that I can provide a pathom/context
map but that seems contrary to the idea of a graph query.
I think it's interesting that this query resolves:
[{[:event "Sign In Forgot Password Submitted"] [{:attributes [:attribute :path :attributeValues]}]}]
I expect that I could provide an ident in the place of :attributes
Am I thinking of pathom wrong?
Iām not very skilled in Pathom but what happens if you put all the context together?:
[{[:event "an event"
:attribute "some attribute"] [:attributeValues]}]