Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:batch? true sometimes makes parts of query unresolvable #194

Open
holyjak opened this issue Mar 23, 2023 · 0 comments
Open

:batch? true sometimes makes parts of query unresolvable #194

holyjak opened this issue Mar 23, 2023 · 0 comments

Comments

@holyjak
Copy link

holyjak commented Mar 23, 2023

The query below fails unless I turn off batch on thefake-order-id resolver or remove :order-line/label-count from the query:

(ns com.tmp
  (:require
    [clojure.test :refer :all]
    [com.wsscode.pathom3.connect.indexes :as pci]
    [com.wsscode.pathom3.connect.operation :as pco]
    [com.wsscode.pathom3.interface.eql :as p.eql]))

(pco/defresolver derived-catalogue-number
  [_env {:keys [:order/yearly-sequence-number :order-line/product]}]
  {::pco/input [:order/yearly-sequence-number
                {:order-line/product [{:product/production-method [:production-method/num-id]}]}
                #_{:order-line/product [:product/production-method]}]
   ::pco/output [:order-line/catalogue-number]}
  {:order-line/catalogue-number
   (str "catalogue-number-seq" yearly-sequence-number "-numid"
        (-> product :product/production-method :production-method/num-id))})
(pco/defresolver derived-label-count
  [_env {:order-line/keys [product package-count]}]
  {::pco/input  [{:order-line/product [:product/labels-per-package]} :order-line/package-count]
   ::pco/output [:order-line/label-count]}
  {:order-line/label-count
   (* package-count (-> product :product/labels-per-package))})
(pco/defresolver fake-order-line-id
  [_env input]
  {::pco/input  [:order-line/id]
   ::pco/output [:order-line/id :order-line/package-count {:order-line/product [:product/id]}]
   ::pco/batch? true}
  (cond-> #:order-line{:id 111
                       :package-count 10
                       :product {:product/id #uuid "cf8b66fb-b963-433f-ab37-af3134061e49"}}
          (sequential? input) vector))
(pco/defresolver fake-order-id
  [_env input]
  {::pco/input  [:order/id]
   ::pco/output [:order/yearly-sequence-number]
   ::pco/batch? true} ; TODO Either set to false to remove label-count from the query to fix
  (cond-> {:order/yearly-sequence-number 33}
          (sequential? input) vector))
(pco/defresolver fake-product-id
  [_env input]
  {::pco/input [:product/id]
   ::pco/output [:product/labels-per-package {:product/production-method [:production-method/id]}]
   ::pco/batch? true}
  (cond-> {:product/labels-per-package 8
           :product/production-method {:production-method/id #uuid "a0269c9d-63a1-4e14-afa3-08f81ab0c002"}}
          (sequential? input) vector))
(pco/defresolver fake-production-method-id
  [_env input]
  {::pco/input  [:production-method/id]
   ::pco/output [:production-method/num-id]
   ::pco/batch? true}
  (cond-> {:production-method/num-id 3}
          (sequential? input) vector))
(pco/defresolver order-line->order
  [_env input]
  {::pco/input  [:order-line/id]
   ::pco/output [:order/id]}
  {:order/id #uuid"72e65f1b-088c-4817-82c9-622aa542ed06"})

(-> (pci/register [derived-catalogue-number derived-label-count fake-order-line-id fake-order-id order-line->order
                   fake-product-id fake-production-method-id])
    (p.eql/process
      {}
      [{[:order-line/id "fake-ol1"]
        [:order-line/id
         :order-line/label-count ; TODO Either remove this or fake-order-id's batch to fix
         :order-line/catalogue-number]}]))

Alternatively, here is output from run-capturing:

#:com.repro{:env {:com.wsscode.pathom3.connect.indexes/index-oir {:order-line/label-count {#:order-line{:product #:product{:labels-per-package {}},
                                                                                                        :package-count {}} #{com.tmp/derived-label-count}},
                                                                  :product/labels-per-package {#:product{:id {}} #{com.tmp/fake-product-id}},
                                                                  :order-line/product {#:order-line{:id {}} #{com.tmp/fake-order-line-id}},
                                                                  :order/id {#:order-line{:id {}} #{com.tmp/order-line->order}},
                                                                  :order-line/catalogue-number {{:order/yearly-sequence-number {},
                                                                                                 :order-line/product #:product{:production-method #:production-method{:num-id {}}}} #{com.tmp/derived-catalogue-number}},
                                                                  :production-method/num-id {#:production-method{:id {}} #{com.tmp/fake-production-method-id}},
                                                                  :order-line/package-count {#:order-line{:id {}} #{com.tmp/fake-order-line-id}},
                                                                  :order/yearly-sequence-number {#:order{:id {}} #{com.tmp/fake-order-id}},
                                                                  :product/production-method {#:product{:id {}} #{com.tmp/fake-product-id}}},
                  :com.wsscode.pathom3.connect.indexes/index-resolvers #:com.tmp{derived-catalogue-number #:com.wsscode.pathom3.connect.operation{:input [:order/yearly-sequence-number
                                                                                                                                                          #:order-line{:product [#:product{:production-method [:production-method/num-id]}]}],
                                                                                                                                                  :provides #:order-line{:catalogue-number {}},
                                                                                                                                                  :output [:order-line/catalogue-number],
                                                                                                                                                  :inferred-input [:order/yearly-sequence-number
                                                                                                                                                                   :order-line/product],
                                                                                                                                                  :op-name com.tmp/derived-catalogue-number,
                                                                                                                                                  :requires {:order/yearly-sequence-number {},
                                                                                                                                                             :order-line/product #:product{:production-method #:production-method{:num-id {}}}}},
                                                                                 derived-label-count #:com.wsscode.pathom3.connect.operation{:input [#:order-line{:product [:product/labels-per-package]}
                                                                                                                                                     :order-line/package-count],
                                                                                                                                             :provides #:order-line{:label-count {}},
                                                                                                                                             :output [:order-line/label-count],
                                                                                                                                             :inferred-input [:order-line/product
                                                                                                                                                              :order-line/package-count],
                                                                                                                                             :op-name com.tmp/derived-label-count,
                                                                                                                                             :requires #:order-line{:product #:product{:labels-per-package {}},
                                                                                                                                                                    :package-count {}}},
                                                                                 fake-order-line-id #:com.wsscode.pathom3.connect.operation{:input [:order-line/id],
                                                                                                                                            :provides #:order-line{:id {},
                                                                                                                                                                   :package-count {},
                                                                                                                                                                   :product #:product{:id {}}},
                                                                                                                                            :output [:order-line/id
                                                                                                                                                     :order-line/package-count
                                                                                                                                                     #:order-line{:product [:product/id]}],
                                                                                                                                            :batch? true,
                                                                                                                                            :op-name com.tmp/fake-order-line-id,
                                                                                                                                            :requires #:order-line{:id {}}},
                                                                                 fake-order-id #:com.wsscode.pathom3.connect.operation{:input [:order/id],
                                                                                                                                       :provides #:order{:yearly-sequence-number {}},
                                                                                                                                       :output [:order/yearly-sequence-number],
                                                                                                                                       :batch? true,
                                                                                                                                       :op-name com.tmp/fake-order-id,
                                                                                                                                       :requires #:order{:id {}}},
                                                                                 order-line->order #:com.wsscode.pathom3.connect.operation{:input [:order-line/id],
                                                                                                                                           :provides #:order{:id {}},
                                                                                                                                           :output [:order/id],
                                                                                                                                           :op-name com.tmp/order-line->order,
                                                                                                                                           :requires #:order-line{:id {}}},
                                                                                 fake-product-id #:com.wsscode.pathom3.connect.operation{:input [:product/id],
                                                                                                                                         :provides #:product{:labels-per-package {},
                                                                                                                                                             :production-method #:production-method{:id {}}},
                                                                                                                                         :output [:product/labels-per-package
                                                                                                                                                  #:product{:production-method [:production-method/id]}],
                                                                                                                                         :batch? true,
                                                                                                                                         :op-name com.tmp/fake-product-id,
                                                                                                                                         :requires #:product{:id {}}},
                                                                                 fake-production-method-id #:com.wsscode.pathom3.connect.operation{:input [:production-method/id],
                                                                                                                                                   :provides #:production-method{:num-id {}},
                                                                                                                                                   :output [:production-method/num-id],
                                                                                                                                                   :batch? true,
                                                                                                                                                   :op-name com.tmp/fake-production-method-id,
                                                                                                                                                   :requires #:production-method{:id {}}}},
                  :com.wsscode.pathom3.connect.indexes/index-mutations {},
                  :com.repro/capture-context #:com.repro{:op-capture #:com.tmp{fake-order-line-id {[[#:order-line{:id "fake-ol1"}]
                                                                                                    {}] [#:order-line{:id 111,
                                                                                                                      :package-count 10,
                                                                                                                      :product #:product{:id #uuid"cf8b66fb-b963-433f-ab37-af3134061e49"}}]},
                                                                               fake-product-id {[[#:product{:id #uuid"cf8b66fb-b963-433f-ab37-af3134061e49"}]
                                                                                                 {}] [#:product{:labels-per-package 8,
                                                                                                                :production-method #:production-method{:id #uuid"a0269c9d-63a1-4e14-afa3-08f81ab0c002"}}]},
                                                                               derived-label-count {[#:order-line{:product #:product{:labels-per-package 8},
                                                                                                                  :package-count 10}
                                                                                                     {}] #:order-line{:label-count 80}},
                                                                               order-line->order {[#:order-line{:id "fake-ol1"}
                                                                                                   {}] #:order{:id #uuid"72e65f1b-088c-4817-82c9-622aa542ed06"}},
                                                                               fake-production-method-id {[[#:production-method{:id #uuid"a0269c9d-63a1-4e14-afa3-08f81ab0c002"}]
                                                                                                           {}] [#:production-method{:num-id 3}]},
                                                                               fake-order-id {[[#:order{:id #uuid"72e65f1b-088c-4817-82c9-622aa542ed06"}]
                                                                                               {}] [#:order{:yearly-sequence-number 33}]}}}},
            :entity {},
            :request [{[:order-line/id "fake-ol1"] [:order-line/id :order-line/label-count :order-line/catalogue-number]}],
            :result :com.repro/exception-result}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant