Skip to content

Passing Data Down to Other Resolvers #184

Answered by wilkerlucio
dehli asked this question in Q&A
Discussion options

You must be logged in to vote

Hello, happy holidays too! 🎄

There are two approaches I see for this case:

  1. Item probably has some association with a story, so you can some resolver that goes from :item/id to :store/id
  2. If you depend on the store id in all-items, you can add it to the data downwards:
(pc/defresolver all-items
  [{:keys [store/id]}]
  {::pc/output
   [{:items/all
     [:item/id :store/id]}]}
  {:items/all
   (mapv
     #(assoc % :store/id id)
     [{:item/id 0}
      {:item/id 1}
      {:item/id 2}])})

(pc/defresolver store-item-inventory
  [{item-id :item/id store-id :store/id}]
  {:store-item/inventory (+ item-id store-id)})

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@dehli
Comment options

@wilkerlucio
Comment options

@dehli
Comment options

@wilkerlucio
Comment options

@dehli
Comment options

Answer selected by wilkerlucio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants