Fork me on GitHub

I have a problem using crux and pathom and i can't find the problem. I have a resolver that call a function with a datalog query in crux. The first time it is executed all his fine, the crux function is called and return the results. If i call it within a few seconds, the resolver is not called anymore or at least no error is seen. If i call the crux function from the ring query directly it works perfectly. So it seems that crux is ok. If i remove the crux call in the resolver it is call normally and return correctly I have no idea what could be wrong here ? If someone has an idea ? Many thanks


Here is the code for the parser

(def parser
   {::p/env     {::p/reader               [p/map-reader
                 ::p/placeholder-prefixes #{">"}}
    ::p/mutate  pc/mutate-async
    ::p/plugins [(pc/connect-plugin {::pc/register app-registry})


The code for the ring handler

(defn query
  (let [params (clojure.walk/keywordize-keys (:params query))
        q (:query params)]
    (println "ring query" q)
    ; (println (crux-api/get-concept-translations-by-jurisdiction 1 (rand-nth (range 730 750))))
    {:status 200
      (<!! (parser params (clojure.edn/read-string q))))}))


The code for the resolver that only work "sometime"

(pc/defresolver by-jurisdiction-id [{:keys [] :as env} params]
                {::pc/input #{:translation/query}
                 ::pc/output [:translations
                (let [query (parse-query-params env)
                      jurisdiction-id (:jurisdiction/id query)
                      concept-id (:concept/id query)
                      results (crux-api/get-concept-translations-by-jurisdiction)]
                    {:translations []}))


the same without the crux call work perfectly


I also ask on crux channel but can't find a solution ...

Chris O’Donnell15:05:32

Have you tried wrapping the resolver body in a try-catch to see if an exception is getting silently swallowed?


it looks like your resolver's output is invalid for a join


{:translations [..]}


yes i tried to catch error but nothing


output is still the same each time


i did try with something that return the same


your output should be:


💯 4

Many thanks for the answers, but even with this i still have troubles


i found my problem ! I had two resolver with the same output signature but one with an input. It did a conflict apparently. Many thanks for your support


replace Fulco with pathom


@eugen.stan I know I suggested you come here, but now I'm not so sure what the API you are interested in would be. With Pathom there is no static API as such because Pathom receives EQL and sends back the query results.


I'm asking about HTTP API - the one the external developers would use


so Fulcro it is


Well Fulcro sends across the EQL, that it created from the composition of Fulcro component's queries. So again I'm not sure where the static API would be.


the recently released pathom-viz electron/stanadlone app is close as you can get currently without writing any code yourself


Thanks, something like that . it would be great if it can generate docs to be served by static web servers


yeah, there is no static site yet, but you can use the server-side rendering cljs of the above code to implement it


thanks, I will keep that in mind. In the mean time I filed a question issue . It should remain there as docs at least.

👍 4
Michael W16:05:03

How do you tie 2 different datasources to each other? I have 2 different apis, one works off id (ddi), I have that fully wired with resolvers, and can query it. The other api (aci) works off ip address, I have that fully wired with resolvers and can query it. How do I tell the first api that the ip field is what it needs to query from the other api and not the id field?

Michael W17:05:12

(parser {} [{[:ip/ip ""] [:ip/ip :ip/pool :ip/subnet :ip/aci]}])
{[:ip/ip ""] #:ip{:ip "", :pool "17", :subnet "59", :aci :com.wsscode.pathom.core/not-found}}

Michael W17:05:43

(parser {} [{[:aci/ip ""] [:aci/ip :aci/mac]}])
{[:aci/ip ""] #:aci{:ip "", :mac "00:50:56:BB:ED:01"}}


add (pc/alias-resolver2 :ip/ip :aci/ip) to your registry @michael819

Michael W17:05:18

is that a plugin?

Chris O’Donnell17:05:25

No, it's a resolver. It is equivalent to the following two resolvers:

(defresolver ip->aci-resolver [_ input]
  {::pc/input #{:ip/ip}
   ::pc/output [:aci/ip]}
  {:aci/ip (get input :ip/ip)})

(defresolver aci->ip-resolver [_ input]
  {::pc/input #{:aci/ip}
   ::pc/output [:ip/ip]}
  {:ip/ip (get input :aci/ip)})

Michael W17:05:58

I tried that and it didn't work


@michael819 I'm not sure I fully understand your question, but it seems like this might help:

Michael W17:05:27

Thanks, let me play with it some more, I know I am really close since I can query both apis independently I just need to figure out how to wire them together.

Michael W17:05:43

I'm looking at the shard thing now @bear-z


Are your apis independent or there is some field that you can link them on?


Because what souenzzo suggests should do the trick if you just need to connect one field to the other.

Michael W17:05:47

Yeah they have a common field, the ip address


What is the end query you're trying to do?


(parser {} [{[:ip/ip ""] [:ip/ip :ip/pool :ip/subnet :ip/aci]}]) 
I think you need to change it to
(parser {} [{[:ip/ip ""] [:ip/ip :ip/pool :ip/subnet :aci/ip :aci/mac]}])
And use alias-resolver2. That should work

Michael W17:05:16

So I have a DDI (DHCP/DNS/IPAM) that has bad mac addresses in it. I am trying to query for mac addresses that don't match between the systems, they both share the ip as a key.

Michael W17:05:10

I get nils for :aci/ip and :aci/mac


have you registered your (pc/alias-resolver2 :ip/ip :aci) to the parser

Michael W17:05:28

(def ip-aci-alias (pc/alias-resolver2 :ip/ip :aci/ip))$
(def resolvers [aci-ip aci-mac$
                subnet-id subnet-ip subnet-start subnet-end$
                pool-id pool-ip$
                ip-id ip-ip ip-aci-alias])$

Michael W17:05:38

I have $ for end of line


Can you confirm that resolver with #{:aci/ip} input gets called?


There is a pathom-viz standalone app that can make your debugging much easier

Michael W17:05:44

Ah hah! Got it working, thanks @souenzzo @bear-z

Michael W17:05:05

(parser {} [{[:ip/ip ""] [:ip/mac :aci/mac]}])
{[:ip/ip ""] {:ip/mac "05:42:39:84:62:62", :aci/mac "00:50:56:BB:ED:01"}}


Nice! What was the problem?

Michael W18:05:19

I had a typo in some other resolver where it was :aci/id not :aci/ip


Glad you found it!

Michael W18:05:49

The alias ultimately glued the 2 systems together, so thanks again for the help, made my day!

parrot 8