This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-05-06
Channels
- # announcements (5)
- # aws (28)
- # babashka (4)
- # beginners (163)
- # bristol-clojurians (2)
- # calva (4)
- # cider (18)
- # clj-kondo (30)
- # cljs-dev (28)
- # cljsrn (50)
- # clojure (96)
- # clojure-europe (25)
- # clojure-italy (6)
- # clojure-losangeles (1)
- # clojure-nl (4)
- # clojure-sweden (7)
- # clojure-uk (32)
- # clojurescript (39)
- # conjure (74)
- # cursive (12)
- # events (1)
- # fulcro (32)
- # helix (71)
- # jackdaw (2)
- # leiningen (10)
- # off-topic (14)
- # pathom (59)
- # rdf (7)
- # re-frame (6)
- # reitit (28)
- # ring (7)
- # shadow-cljs (207)
- # slack-help (2)
- # spacemacs (3)
- # specter (7)
- # sql (12)
- # tools-deps (14)
- # xtdb (32)
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/async-parser
{::p/env {::p/reader [p/map-reader
pc/async-reader2
pc/ident-reader
p/env-placeholder-reader]
::p/placeholder-prefixes #{">"}}
::p/mutate pc/mutate-async
::p/plugins [(pc/connect-plugin {::pc/register app-registry})
p/error-handler-plugin
p/trace-plugin
params-down-pathom-plugin]}))
The code for the ring handler
(defn query
[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
:body
(encode-transit-json
(<!! (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
[:translation/id
:translation/language
:translation/value
:translation/status
:jurisidction/id
:concept/id
:app/type]]}
(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 []}))
Have you tried wrapping the resolver body in a try-catch to see if an exception is getting silently swallowed?
your output should be:
[{:translations
[:translation/id
:translation/language
:translation/value
:translation/status
:jurisidction/id
:concept/id
:app/type]}]
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
@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.
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.
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?
(parser {} [{[:ip/ip "10.4.94.48"] [:ip/ip :ip/pool :ip/subnet :ip/aci]}])
{[:ip/ip "10.4.94.48"] #:ip{:ip "10.4.94.48", :pool "17", :subnet "59", :aci :com.wsscode.pathom.core/not-found}}
(parser {} [{[:aci/ip "10.4.94.48"] [:aci/ip :aci/mac]}])
{[:aci/ip "10.4.94.48"] #:aci{:ip "10.4.94.48", :mac "00:50:56:BB:ED:01"}}
add (pc/alias-resolver2 :ip/ip :aci/ip)
to your registry @michael819
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)})
@michael819 I'm not sure I fully understand your question, but it seems like this might help: https://wilkerlucio.github.io/pathom/v2/pathom/2.2.0/plugins.html#_example_shard_switch
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.
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.
What is the end query you're trying to do?
(parser {} [{[:ip/ip "10.4.94.48"] [:ip/ip :ip/pool :ip/subnet :ip/aci]}])
I think you need to change it to
(parser {} [{[:ip/ip "10.4.94.48"] [:ip/ip :ip/pool :ip/subnet :aci/ip :aci/mac]}])
And use alias-resolver2. That should workSo 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.
have you registered your (pc/alias-resolver2 :ip/ip :aci)
to the parser
(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])$
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
(parser {} [{[:ip/ip "10.4.94.48"] [:ip/mac :aci/mac]}])
{[:ip/ip "10.4.94.48"] {:ip/mac "05:42:39:84:62:62", :aci/mac "00:50:56:BB:ED:01"}}
Nice! What was the problem?
Glad you found it!