Fork me on GitHub
#pathom
<
2022-10-30
>
caleb.macdonaldblack20:10:41

@wilkerlucio Inferring input from the destructuring doesn’t also infer nesting. What are your thoughts on a change to support this?

(pco/defresolver foo
  [{{{son :son} :father} :grandpa}]
  {:grandpa son})
=> #'com.calebmacdonaldblack.foo/foo
foo
=>
#com.wsscode.pathom3.connect.operation.Resolver{:config #:com.wsscode.pathom3.connect.operation{:input [:grandpa],
                                                                                                :provides {:grandpa {}},
                                                                                                :output [:grandpa],
                                                                                                :inferred-input [:grandpa],
                                                                                                :op-name com.calebmacdonaldblack.foo/foo,
                                                                                                :requires {:grandpa {}}},
                                                :resolve #object[com.calebmacdonaldblack.foo$foo__21752
                                                                 0x6f873565
                                                                 "com.calebmacdonaldblack.foo$foo__21752@6f873565"]}

wilkerlucio22:11:10

hello, that's by design

wilkerlucio22:11:32

yes, we could support it, but I think at that point is better to have it explicitly, otherwise its kinda painful to read

caleb.macdonaldblack20:10:39

Some examples of what I mean

(deftest extract-destructure-map-as-input-test


  (testing "Simple flat params"
    (is (= [:foo :bar]
           (extract-destructure-map-as-input
             '{foo :foo
               bar :bar}))))

  (testing "Nested input"
    (is (= [{:foo [{:bar [:buzz :y :a :b :c]}
                   :x]}]
           (extract-destructure-map-as-input
             '{{{fizz :buzz y :y :keys [a b c]} :bar x :x} :foo}))))

  (testing "Nested input with vector destructuring"
    (is (= [:foo]
           (extract-destructure-map-as-input
             '{[foo1 foo2] :foo}))))

  (testing "Nested input with vector destructuring and more nesting"
    (is (= [{:foo [:bar]}]
           (extract-destructure-map-as-input
             '{[{bar :bar}] :foo}))))

  (testing "Simple flat params with symbol keys"
    (is (= [:foo :bar]
           (extract-destructure-map-as-input
             '{:keys [foo bar]}))))

  (testing "Simple flat params with keyword keys"
    (is (= [:foo :bar]
           (extract-destructure-map-as-input
             '{:keys [:foo :bar]}))))

  (testing "Simple flat params with namespaced symbol keys"
    (is (= [:ns/foo :ns/bar]
           (extract-destructure-map-as-input
             '{:keys [:ns/foo :ns/bar]})))))