Fork me on GitHub
#pathom
<
2022-06-01
>
nivekuil08:06:09

anyone plug pathom 3's traces into opentelemetry/zipkin? I already have traces set up with mulog but not sure how to integrate those with pathom's built in tracing

danieroux09:06:14

I haven't look at this yet, but I am very interested in this too.

roklenarcic09:06:24

when creating a resolver, what should ::pco/params contain? A vector of param keywords? [:id] ?

dehli11:06:19

params is only used for mutations so you shouldn't specify that key. ::pco/input is what resolvers use and it is a vector of keywords (or maps if you wanted to specify nested inputs)

wilkerlucio12:06:12

resolvers can get params too, the format is EQL, same as input and output, the description doesnt affect anything in terms of running, but can be used in the future to support tools like pathom viz

dehli12:06:27

Oh that's right! I've used them with things like pagination for a resolver. Forgot about that.

dehli12:06:49

(swap! (::pcr/resolver-cache* env)
       dissoc
       ['fully.qualified/op-name
        {:resolver/input true}
        {}])
I've used the above code to invalidate a resolver cache. The empty object as a 3rd argument is b/c the resolver I was invalidating didn't take params. If your resolver does use params, you'd need to also take that into account.

nivekuil12:06:58

where are you getting :resolver/input from? I assumed that would be the same input you destructure in the resolver, but the extra stuff going on in that function I linked gives me pause

dehli13:06:49

:resolver/input is just an example of what the input map could be. If you had the following resolver

(ns my.namespace)

(pco/defresolver my-resolver
  [{input :my/input}]
  {:my/output (str "out: " input)})
and you wanted to invalidate the cache for input of "foo" you would do:
(swap! (::pcr/resolver-cache* env)
        dissoc
        ['my.namespace/my-resolver
         {:my/input "foo"}
         {}])
Does that make sense?

nivekuil13:06:02

it's not clear to me that

input-data      (pfsd/select-shape-filtering entity (pfsd/merge-shapes input optionals) input)         input-data      (pcr/enhance-dynamic-input r-config node input-data)
are just no-ops and you can do it that simple way, or if they need to be accounted for, which seems like exposing my code to pathom internals

wilkerlucio14:06:48

@U797MAJ8M do you want to do a precise invalidation (for one specific input/params set) or looking for to clear the cache for all entries for a specific resolver?

wilkerlucio14:06:52

because if you are looking for the later, I suggest using a separete cache store for it (https://pathom3.wsscode.com/docs/cache#custom-cache-store-per-resolver), this will make trivial to clear the whole cache on that store (just reset it to {})

wilkerlucio14:06:03

just remember that to make it work as the default cache store, you will also need a plugin to reset that store for each request, otherwise it will behave more like a durable store (in the sense it will live though multiple requests, instead of per request)

wilkerlucio14:06:39

you can use this built-in plugin to help creating a new cache store for that name on each request: https://pathom3.wsscode.com/docs/built-in-plugins#extend-environment

wilkerlucio15:06:26

another thing that you may find interesting, is the config ::pco/cache-key, you can use this to provide a function that generates the cache key for that resolver, instead of using the standard [op-name input params] form

wilkerlucio15:06:25

the function on ::pco/cache-key will take [env input-data] as arguments

nivekuil15:06:31

ah, cache-key is what I want, thanks

wilkerlucio15:06:46

keep in mind that if you don't change the cache store, you are sharing it in a flat map with the cache of every other resolver, so make sure you are not doing anything that may conflict cache keys