Will dbl check the docs, etc
We got asked today the possibility to expose our pathom api as a graphql api. i know this has been discussed several times and there are attempts like https://github.com/denisidoro/graffiti but do you think it would make sense to relay on pathom3's smart maps as lacinia resolvers? so basically we would create the graphql schema define the root queries attaching resolvers that use smartmaps
I would avoid smart maps for this use case, doing large queries one attribute at a time isnt very efficient, and some queries will pay more than others
I think there is some work to be done, like Grafitti to improve that story
not on my radar at this time, but I can help if anyone wants to try that direction
(please disregard the namespace name - I'm not sure this is a bug 🙂 )
I have a resolver called "dimension-attributes" which can produce an array of raw data which another resolver formats into something - in this example, that formatting has trivial logic in the id-event-level resolver. Finally, I have a resolver field-list which reformats the data into something suitable for the pivot table UI widget
The dimension-attributes resolver can produce an empty array
When the dimension-attributes resolver produces an empty array, the reformatting resolver (field-list) is not invoked and, so, the field-list resolver is not invoked. This results in the wrong data sent to the UI
I've tried various combinations of pco/?
but I cannot find the right combination to get the result I'm looking for.
Am I going about this the wrong way?
Thanks for the input wilker. It's probably something we will need to implement at some point. I can start looking at it, is the graffiti code a good place to start ?
the problem is when you return an empty array you’re not returning those keys (`:key`, :some
, and :data
) so pathom won’t be able to invoke the id-event-level
resolver (which is how your field-list’s attribute-id
input can be fulfilled). what would you like the response of (:>/input {:key "empty"})
to be?
Instead of returning a vector would this work?
(pco/defresolver dimension-attributes [{:keys [key]}]
{::pco/input [:key]
::pco/output [{:attributes/dimensions [:key :some :data]}]}
{:attributes/dimensions (when (not= key "empty")
{:key "key"
:some "a"
:data "b"})})
(pco/defresolver id-event-level [input]
{::pco/input [(pco/? :key) (pco/? :some) (pco/? :data)]}
{:attribute/id input})
;; Keep the rest the same
When you return an empty array, there’s nothing for pathom to iterate on which is the real issue with your original code (and why using a combination of (pco/?)
probably wasn’t working).