This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-28
Channels
- # babashka (48)
- # babashka-sci-dev (7)
- # beginners (123)
- # calva (32)
- # cider (5)
- # clara (20)
- # clj-kondo (3)
- # cljdoc (2)
- # cljs-dev (1)
- # clojure (113)
- # clojure-dev (5)
- # clojure-europe (65)
- # clojure-norway (23)
- # clojure-spec (4)
- # clojure-uk (4)
- # clojurescript (33)
- # cursive (3)
- # datalevin (39)
- # datomic (2)
- # emacs (14)
- # events (1)
- # fulcro (10)
- # graphql (5)
- # humbleui (2)
- # integrant (4)
- # introduce-yourself (3)
- # jobs (1)
- # jobs-discuss (11)
- # kaocha (26)
- # leiningen (6)
- # malli (24)
- # nbb (2)
- # off-topic (69)
- # pathom (77)
- # podcasts-discuss (2)
- # reitit (8)
- # remote-jobs (2)
- # sci (17)
- # scittle (8)
- # squint (1)
- # xtdb (43)
I'm trying out full-stack dynamic resolvers in fulcro, but it looks like it will slow down first load because the app initialization needs to be async to wait one round trip for the indexes to be fetched first. Any better way to do it? ideally the indexes could be fetched along with the html/css/js and held in a CDN
what do you mean by "full-stack dynamic resolvers"?
gotcha, so, it really depends on when/how you initialize it, I dont have any mechanism to cache, but there is a way to “trick it”, by wrapping the boundary interface with a fn, and intercepting the request for indexes
Im afk now, but I can send an example later
if you have an example for getting this working at all I'd love to see it. my attempt failed, I believe I couldn't figure out why the boundary-interface seemed to work in the repl but when fulcro calls it a lot of attributes return "Batch error: cannot write Function"
also there was ::p/not-found
coming from somewhere and I don't even see that in the pathom code
the error sounds like some encoding issue, which could explain the fail on remote, but not in the repl
p not found is weird, thats not a thing in pathom 3
well, when I say repl I mean cljs browser repl, and it's using the same transit stuff as the normal fulcro http remote
are you using pathom3 in both ends?
because thats a regular pathom na
makes, could be
so if the error-stack
only has .js files then the error happened on the client? does it also do full-stack stacktraces?
full code
(defn api-request [body]
(-> (js/fetch (str js/window.location.origin "/api")
#js {:method "POST"
:headers #js {"Content-Type" "application/transit+json"
"Accept" "application/transit+json"}
:body (fulcro-transit/transit-clj->str body)
})
(p/then (fn [response] (.text response)))
(p/then' (fn [response] (log/spy (fulcro-transit/transit-str->clj response))))))
(def pathom
(p/let [api (pcf/foreign-register api-request)]
(let [env (-> #_(p.plugin/register [init-state-plugin])
(pci/register [api])
)]
(p.a.eql/boundary-interface env))))
actually strike all that, I realized that I actually had the resolver definition wrong but this was asymptomatic unless using dynamic resolvers
still, doesn't work with fulcro since the cljs writer tries to serialize a Function for some reason
Im very interested in your experience, afaik no one is using it that way, so I expected rough edges, and interested in fixing them :)
that rel with fulcro is something we can investigate
does your transit encoder understands pathom resolvers/mutations?
they are a special type, and pathom providers readers/writters for them
can you provide an example repo with the things you are trying? I like to see closer
and try myself
it would have to be the whole fulcro project, I can try making a smaller example later
I see the problem, it's in the AST that is passed by the boundary interface to the http request. looking at the ast, :component
is actually a function, I think it should be a symbol?
{:type :join,
:dispatch-key :user/views,
:key :user/views,
:query [:view/id :view/title],
:component app.ui.view-meta/UserView,
:children [{:type :prop, :dispatch-key :view/id, :key :view/id}
{:type :prop,
:dispatch-key :view/title,
:key :view/title}]}
so I call (boundary-interface query)
and this is correct, then pathom calls the foreign-registered api-request
with a bad AST
I think I can instead of using EQL, pass a cleaned up AST directly to the boundary interface
yes you can :)
so I'm guessing that the EQL->AST writes the component metadata that fulcro attaches as functions and that's what's breaking transit
quite possible
one good thing is to make transit more resilient, by setting up a default handlwe
on the writer
oh, I remember you mentioning this now.. the default-handler doesn't work in cljs right
this look like a bug?
(p/let [res1 (api-request [{:app.api.wikidata/recent-tags [{:>/tag {:tag/qid [:wiki/label]}}]}])
res2 (api-request [{:app.api.wikidata/recent-tags [{:tag/qid [:wiki/label]}]}])]
(println res1)
(println res2))
{:app.api.wikidata/recent-tags [{:>/tag {}} {:>/tag {}} {:>/tag {}} {:>/tag {}} {:>/tag {}} {:>/tag {}}]}
{:app.api.wikidata/recent-tags [{:tag/qid {:wiki/label flag semaphore}} {:tag/qid {:wiki/label microscope}} {:tag/qid {:wiki/label WebTransport}} {:tag/qid {:wiki/label benchmark}} {:tag/qid {:wiki/label Craigslist}} {:tag/qid {:wiki/label Z shell}}]}
I see a join missing a vector after :>/tag
ok this one, 50% sure I didn't mess up
(p/let [p pathom
res1 (p [{[:wiki/id 9061] [{:wiki/claims [:wiki/predicate {:>/wiki-item [:wiki/id :wiki/label]}]}]}])
res2 (p [{[:wiki/id 9061] [{:wiki/claims [:wiki/predicate :wiki/id :wiki/label]}]}])]
(println res1)
(println res2)
)
{[:wiki/id 9061] {:wiki/claims [{:wiki/predicate 106} {:wiki/predicate 737} {:wiki/predicate 106} {:wiki/predicate 106} {:wiki/predicate 101} {:wiki/predicate 106} {:wiki/predicate 31} {:wiki/predicate 800} {:wiki/predicate 106} {:wiki/predicate 101} {:wiki/predicate 106} {:wiki/predicate 106} {:wiki/predicate 737} {:wiki/predicate 106} {:wiki/predicate 106} {:wiki/predicate 101} {:wiki/predicate 800} {:wiki/predicate 800} {:wiki/predicate 737} {:wiki/predicate 101} {:wiki/predicate 800} {:wiki/predicate 737} {:wiki/predicate 361}]}}
{[:wiki/id 9061] {:wiki/claims [{:wiki/predicate 106, :wiki/id 188094, :wiki/label economist} {:wiki/predicate 737, :wiki/id 76725, :wiki/label Max Stirner} {:wiki/predicate 106, :wiki/id 201788, :wiki/label historian} {:wiki/predicate 106, :wiki/id 4964182, :wiki/label philosopher} {:wiki/predicate 101, :wiki/id 159810, :wiki/label economy} {:wiki/predicate 106, :wiki/id 2306091, :wiki/label sociologist} {:wiki/predicate 31, :wiki/id 5, :wiki/label human} {:wiki/predicate 800, :wiki/id 58784, :wiki/label Das Kapital} {:wiki/predicate 106, :wiki/id 3242115, :wiki/label revolutionary} {:wiki/predicate 101, :wiki/id 5891, :wiki/label philosophy} {:wiki/predicate 106, :wiki/id 1930187, :wiki/label journalist} {:wiki/predicate 106, :wiki/id 36180, :wiki/label writer} {:wiki/predicate 737, :wiki/id 9235, :wiki/label Georg Wilhelm Friedrich Hegel} {:wiki/predicate 106, :wiki/id 49757, :wiki/label poet} {:wiki/predicate 106, :wiki/id 82955, :wiki/label politician} {:wiki/predicate 101, :wiki/id 8134, :wiki/label economics} {:wiki/predicate 800, :wiki/id 40591, :wiki/label The Communist Manifesto} {:wiki/predicate 800, :wiki/id 295347, :wiki/label Economic and Philosophic Manuscripts of 1844} {:wiki/predicate 737, :wiki/id 76422, :wiki/label Ludwig Feuerbach} {:wiki/predicate 101, :wiki/id 21201, :wiki/label sociology} {:wiki/predicate 800, :wiki/id 470600, :wiki/label The German Ideology} {:wiki/predicate 737, :wiki/id 1170769, :wiki/label The Essence of Christianity} {:wiki/predicate 361, :wiki/id 1518091, :wiki/label Marx siblings}]}}
check after :>/wiki-predicate, I think its missing the vector there
osrry, I mistyped, haa, but check after :wiki/predicate
ah, sorry, I misread, reading from the phone,rsrs
ir might be a bug
the placeholder query works correctly through pathom-viz.. doesn't that use the same foreign env/boundary resolver
it may be something in the foreign integration
you are using pathom viz connected to the cljs env or to the server env?
you can do with the pathom viz connector
ah right, that has the ip/host issues we went over earlier.. I should get around to a PR sometime
@U066U8JQJ I also ran into some issues with a placeholder something seems to go wrong with the foreign interface and placeholders. It is fixed if I query the properties one place higher then the placeholder
so
{:foo/id {:>/placeholder [:foo/name]}}
Fails with cannot find path to [:>placeholder :foo/name]
{:foo/id :foo/name {:>/placeholder [:foo/name]}}
Fixes itok, that totally looks like a bug
can you please start an issue about it?
Yes I managed to reproduce it in a small reproducible case: https://github.com/wilkerlucio/pathom3/issues/159
thank you!
seems like I can get some requests working but merging into fulcro is broken.. anyone try this yet?
You can look at the server-side render stuff from Fulcro. There are functions to encode and decode initial-state into the HTML. So you have some state without having to make a request. I use it for translation strings for example.