Fork me on GitHub
#pathom
<
2021-11-11
>
mauricio.szabo01:11:46

Hi, just checking if I can somehow make this modeling work. I have multiple resolvers for the same attributes, and they are prioritized and working. The problem is that some resolvers return more attributes than others. For example, resolver outputs :a, and resolver B outputs :a and :b, and have less priority.

mauricio.szabo01:11:12

Now for the problem - I want resolver A to somehow signal "I found :a, and :b doesn't make sense in this context, so don't try to resolve this attribute" Currently I'm returning nil, but I really don't like to use nil in my code - is there a better way?

jmayaalv11:11:26

how do you determine that an attr doesn’t make sense in a given context?

mauricio.szabo12:11:21

That's what I want to know how to do it in Pathom 😄. But if you're asking like "more conceptually, in your code", it's because I'm trying to make a bunch of resolvers to drive Clojure plug-ins. In my specific case, I'm implementing "go to var definition" and friends. So, for example, if I want to "go to var defintion" for a var, and I find that the file is inside a JAR, it makes sense to get the contents of the file, uncompressed. But something things conflict: for example, if I find a file that is already on the current filesystem, and don't return its contents, the resolvers will keep trying to find a resolver that may get the contents, and sometimes this translates to "doing the wrong thing"

jmayaalv14:11:44

got the point, actually i think we have a similar problem 🙂 something we were going to try was a to create a plugin where you register the optional outputs of a given resolver. something like:

(defresolver a-resolver []
  {::pco/optional [:b :c]}
....)
and the plugin basically would add the nulls if not present. i am not a big fan either of this so it would be great to hear a different solution 🙂

souenzzo12:11:59

What is the difference between eql/focus-subquery and eql/mask-query ?! There is some (historical) reason to have these two?

lilactown18:11:43

i'm interested in this too

wilkerlucio21:11:54

I took a look at the code, they really seem the same, my guess is that at some point I wanted the mask and couldn't find the focus-subquery and ended up remaking it... but by looking at the sources you should prefer focus-subquery, the implementation is more complete, and supports unions

wilkerlucio21:11:07

I wanna look closer to make sure this is the case, if so I'll deprecate mask-subquery

👍 1
souenzzo23:11:27

They behave a bit differently in some edge cases

((juxt (partial apply eql/mask-query)
   (partial apply eql/focus-subquery))
 [[:a {:b [:c]}]
  [:a {:b []}]])
=> [[:a {:b [:c]}] [:a {:b []}]]

pithyless14:11:34

@wilkerlucio I'm studying your pathom-viz codebase and I think you've got a typo: https://github.com/wilkerlucio/pathom-viz/blob/de5fcb8f6ddc0acfbc834cf0c811d1de36fa39d2/src/core/com/wsscode/pathom/viz/helpers.cljs#L346 (-swap! [a f x y more] ,,,) should be (-swap! [a f x y & more] ,,,) - right?

pithyless14:11:24

If so, FulcroComponentProp and ReactAtomState have the same bug. Unless I misunderstood the code.

wilkerlucio14:11:26

I believe this is correct though, its a protocol related thing, I remember going over this in the past, but would be nice to validate it, if you look at the ISwap protocol, you will see this:

wilkerlucio14:11:28

(defprotocol ISwap
  "Protocol for adding swapping functionality."
  (-swap! [o f] [o f a] [o f a b] [o f a b xs]
    "Swaps the value of o to be (apply f current-value-of-atom args)."))

pithyless14:11:51

You're right, the protocol is correct and I confused swap! with -swap!. Sorry for the false alarm :)

sheluchin15:11:27

I'm a little confused about how to use p/trace-plugin with Fulcro RAD. I've added p/trace-plugin as part of the extra-plugins vector here https://github.com/fulcrologic/fulcro-rad-demo/blob/a55b33ae82f372c26ee51b67c6c9b74a07a2cbeb/src/xtdb/com/example/components/parser.clj#L48. Then what? Where can I see the trace results?

sheluchin15:11:57

Ah, I see now, the response contains some new information:

{:start 1,
  :path [],
  :duration 14,
  :details [{:event "trace-done", :duration 0, :start 15}],
  :children
  [...

sheluchin16:11:02

Any tips on how to get a visualization working? I see trace->viz but haven't yet figured out how to get that to work from my trace output.

wilkerlucio21:11:48

this is intended to use with Fulcro Inspect or Pathom Viz, these tools have code to render this trace data

sheluchin21:11:27

Alright, so I use Inspect. Where in there can I find the tracer stuff? Sorry, I must be missing something really obvious..

wilkerlucio21:11:56

maybe not so obvious, but can you try running a query from fulcro inspect query tab? ensure the checkbox for “Request Trace” is on

wilkerlucio21:11:37

to get the trace you need to add :pathom/trace to the query, this is what the checkbox there does

wilkerlucio21:11:01

what people usually do is some server config to always add that in dev mode

sheluchin21:11:34

I do not see "Request Trace". You mean in the EQL tab, yeah?

sheluchin21:11:04

It looks like I have latest installed too, 3.0.5.

sheluchin21:11:52

Ah, under Network at the very bottom. I see the profiler there now. But I still don't see Request Trace anywhere.

sheluchin22:11:40

I notice the profiler doesn't show up at the bottom for all requests in the Network tab. For example, if I create a request through my UI, that doesn't have the profiler timeline at the bottom. If I then press Send to query and re-issue the request from the EQL tab, the new log entry in Network does have the profiler timeline at the bottom. I guess this might be why I missed it before. I still don't see the checkbox you speak of though.

wilkerlucio01:11:51

this is the server configuration part I talked about, for tracing data to be available you need to add :com.wsscode.pathom/trace to the query, a simple way to do that is to wrap your parser in another fn like:

(defn traced-parser [tx]
  (parser (conj tx :com.wsscode.pathom/trace))
But you can make this query modification in any layer that makes sense in your system, could be also from the UI for example, modifying the network request from the Fulcro remote https://blog.wsscode.com/pathom/v2/pathom/2.2.0/core/trace.html