This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-02-21
Channels
- # announcements (39)
- # architecture (7)
- # aws (9)
- # babashka (111)
- # beginners (139)
- # bristol-clojurians (1)
- # calva (47)
- # chlorine-clover (5)
- # cider (17)
- # clj-kondo (26)
- # clojars (25)
- # clojure (251)
- # clojure-berlin (1)
- # clojure-dev (5)
- # clojure-europe (22)
- # clojure-france (1)
- # clojure-hungary (6)
- # clojure-losangeles (8)
- # clojure-nl (18)
- # clojure-spec (3)
- # clojure-uk (68)
- # clojured (32)
- # clojurescript (32)
- # core-async (10)
- # core-typed (120)
- # cursive (8)
- # datascript (10)
- # datomic (11)
- # docker (2)
- # emacs (6)
- # figwheel-main (4)
- # fulcro (10)
- # graalvm (92)
- # hoplon (2)
- # instaparse (9)
- # jobs (3)
- # jobs-discuss (31)
- # joker (2)
- # kaocha (1)
- # lambdaisland (5)
- # leiningen (10)
- # luminus (1)
- # lumo (14)
- # meander (30)
- # mid-cities-meetup (1)
- # midje (1)
- # off-topic (46)
- # pathom (22)
- # perun (2)
- # re-frame (10)
- # reitit (1)
- # remote-jobs (8)
- # shadow-cljs (71)
- # spacemacs (7)
- # sql (40)
- # tools-deps (31)
- # tree-sitter (11)
- # vim (14)
- # vscode (2)
- # xtdb (5)
noob question: Is there a pathom ring handler and corresponding cljs client for making pathom queries anywhere? Or do people hand roll this each time; or am I misunderstanding something?
@austin021 I'm not sure if I understand, a resolver should only be called if the inputs can be satisfied, can you send an example that demonstrates what you are saying?
@rickmoynihan hello Rick, not sure what you mean, when I'm doing a server I usually roll an endpoint and put the parser to work on it, many times I juts use it in CLJS directly, so there is not need for server setup in these cases, what kind of setup are you looking into doing?
@wilkerlucio I’m more at the pondering stage right now, than actively looking at implementing anything — but was essentially thinking about having a single endpoint/route to serve EQL requests from cljs front end components
@rickmoynihan maybe this could be helpful to you to see. This is what I do. I am sending my data over in transit form (although it isn't necessary I could just send the raw query. Here is a link to it though https://github.com/cognitect/transit-format). This is in hooked into an Ion since I am running it in the cloud and my query is placed in the body of the request at the :input
(defn untransitize [query]
(transit/read
(transit/reader
(ByteArrayInputStream. (.getBytes query))
:json)))
(defn eql-query
"run eql query into pathom and return the transitized result"
[{:keys [context input]}]
(let [query (untransitize input)
response (<!! (parser {} query))
out (ByteArrayOutputStream. 4096)]
(transit/write (transit/writer out :json) response)
(str out)))
I've then listed the eql-query function in my ion config like so
:lambdas {:eql-query
{:fn my-namespace/eql-query
:description "run eql query into pathom and return the transitized result"}}
and now I have an endpoint I can just throw eql queries at. In my case they are using transit, but I could very easily just use the raw query. Does this help?@brian.rogers: thanks, that’s exactly the kind of thing I was expecting to do
Hm, how do I translate this example query in GraphQL into pathom eql query?
{
countries(where: {name: {eq: "United Kingdom"}}) {
cities {
name
population
}
}
}
Currently I have
::pcg/prefix "eb"
::pcg/ident-map {"countries" {"where" :eb.Country/where}}
and then I tried query:
(parser {} [[:eb.Country/where {:name {:eq "United Kingdom"}}]])
I don’t think I understand this ident map correctly I guess
@roklenarcic I think you are blending edn data and eql queries without meaning to. Or perhaps blending datomic pull syntax and eql queries. That looks to me like you're putting pull syntax into an eql query
I'm imagining a resolver where the input would be a country name and the output would be :population
in which case your parser and query call would look something like this:
(parser {} [{[:name "United Kingdom"][:population]}])
here you're saying in the first square brackets that you have an input of :name
and you want pathom to give you a :population
. This could be used with a resolver like this
(pc/defresolver population-resolver [_ {:keys [name]}]
{::pc/input #{:name}
::pc/output [:population]
{:population (get-population-function name)}})
and you'd need to write the get-population-function
yourself and query your database, likely with pull syntaxfrom the query I guess @roklenarcic is trying to use pathom to connect to a hasura graphql server?
I am not mixing. But the where parameter is complex and judging by pathom docs i need to put as the ident
Sorry on phone now
@myguidingstar everbase graphql
You need to parameterize your query; it should look something like this:
[{'(:my.prefix/countries {:where {:name {:eq "United Kingdom"}}}) [{:my.prefix/cities [:my.prefix/name :my.prefix/population]}]}]
Hey y'all I've got a question regarding using transit-js to turn some js into a pathom query. I think this is more transit-based but perhaps someone can identify my issue.
My issue has to do with the '
character and ()
characters in the query:
[{'([:num1 1] {:pathom/context {:num2 1 :num3 1}})
[:sum]}]
because I am using multiple inputs, I'm using a query like this which I've only gotten to work with that '
character and the following (
character which encompasses most of the rest of the query.
On the javascript side I'm having a lot of problem turning that into transit because javascript expects different things from the parentheses characters.
transit.map([
[(transit.keyword("num1"), 1], {
// pathom/context part should go here, but the parenthesis screws it all up
}),
[transit.keyword("ip-blacklisted?")]
])
So 1) does anyone know how I can recreate that query using transit of any language implementation (preferably js of course)? Or 2) does anyone know how I can rewrite the query so that it's less convoluted and therefore easier for me to convert with transit?@brian.rogers you only need '
in clojure code, not edn strings
And the ()
characters denote a list. Use transit.list
to produce one