Fork me on GitHub
#fulcro
<
2019-09-30
>
wilkerlucio01:09:31

@tony.kay hello, using Fulcro 3, I'm trying to wrap my network so I get pathom traces during development, but I can't figure how to make that work... I tried using a request middleware

(fulcro-http/fulcro-http-remote
  {:url                ""
   :request-middleware (let [wrapper (fulcro-http/wrap-fulcro-request)]
                         (fn [req]
                           (let [req' (update req :body conj :com.wsscode.pathom/trace)]
                             (wrapper req'))))})
also trying wrapping the remote completely:
(let [remote (fulcro-http/fulcro-http-remote
               {:url ""})]
  {:transmit! (fn [x req]
                (let [req' (update-in req [::txn/ast :children] conj {:type :prop
                                                                      :key  :com.wsscode.pathom/trace
                                                                      :key  :com.wsscode.pathom/trace})]
                  ((:transmit! remote) remote req')))})

wilkerlucio01:09:44

but the source seems to never get modified in Inspect

wilkerlucio01:09:23

is there a way to make this affect the inspect so the request goes with trace?

tony.kay03:09:01

@wilkerlucio So, Inspect is sent messages from the tx processing separate from the low-level networking

tony.kay03:09:29

try the global-eql-transform option to the app itself. I think that is applied before it reaches that layer

tony.kay03:09:11

I can have a look tomorrow if that doesn’t work

wilkerlucio14:09:22

@tony.kay thanks, I just tried, seems like the trace is correctly add to the query, but for some reason the response is not picking up

wilkerlucio14:09:34

if I get the same query and use Send to query and then send from there, it works

wilkerlucio14:09:07

I guess maybe the response merge is not considering the modified query

tony.kay14:09:57

hm. could be a bug. I’m mainly using it to strip things, not add them

tony.kay14:09:40

data fetch ns has the logic…it’s all in the load mutation implementation

tony.kay14:09:47

in data_fetch.cljc

tony.kay14:09:04

finish-load!

tony.kay14:09:34

which uses the query that it got from the generated load params

tony.kay14:09:48

which uses update-query, which in turn defaults to global-eql-transform

tony.kay14:09:03

so, are you using both? That would mess with it

tony.kay14:09:24

oh…actually

tony.kay14:09:34

there is a bug I think

tony.kay14:09:52

line 266…I accidentally made two transforms

tony.kay14:09:57

:query-transform-default is used as the default for load…`global-eql-transform` is at the network layer

tony.kay14:09:39

I think that might have been intentional now that I’m revisiting it. The former is for changing queries for loads, and the other is for doing “behind the scenes” augments nearer the network layer (which can include messing with mutations)

tony.kay14:09:09

but only the former would be seen as part of merge

tony.kay14:09:21

This particular concern: getting trace data to inspect…I think we need an addl “event” that sends that to inspect

tony.kay14:09:27

I don’t want that merged with state (by tooling)

tony.kay14:09:32

Much better to put something at the network layer that asks for it (which is what you just did) and something else that looks for it in the response and sends an event to inspect

wilkerlucio15:09:19

yeah, there are pros and cons on having it on state, I think it helps with clarify when its part of the DB, being nothing special, this allows debugging the data from the trace if needed so

wilkerlucio15:09:35

I just tried using :query-transform-default, but no effect there

tony.kay15:09:23

as a (conj query ::pathom/trace)?

tony.kay15:09:55

ok, that is a bug…I think I see it…just a min. These corner case things get used so rarely 😜

tony.kay15:09:59

no…take that back…it looks fine

tony.kay15:09:09

But in any case: I see the pathom trace as a pure tooling issue, not something for the client application layer (unless the app layer itself is implementing trace viewing). Therefore, there is no reason you should have to configure it at all (other than to have Inspect open and attached to the application, and perhaps a “show trace” option enabled).

tony.kay15:09:45

So, I’d say we should add an addl hook that lets Inspect turn on/off tracing (which sends that message to the app), and then logic at the network layer that adds in the query bit and pulls off the trace result to send to inspect.

tony.kay15:09:32

(we can delay the toggle until later if we want, and make it purely an app config option)

Piotr Roterski23:09:24

Hey, is @currentoor's Fulcro presentation from Clojure South available anywhere on the internet yet? It was announced here on slack earlier and I wouldn't want to miss it. 😊