Fork me on GitHub
λustin f(n)00:02:39

I am noticing that resolvers with multiple inputs sometimes try to resolve even when all the inputs are not present. Is there a way to require every input? In my case, I have some simple resolvers that take a bunch of keys and put them into a map under a new keyword. If there is 'enough' attributes it returns it with the keys it had, but if there is only one or two of them it returns :com.wscode.pathom.core/not-found


are you sure they don’t try resolve when the inputs just have nil values? that’s different from absence

λustin f(n)21:02:47

Pretty sure. I put logging in the resolver, and the input to the resolver is missing one of the values entirely even though the inputs has it listed.

λustin f(n)21:02:17

I am trying to put together the simplest thing that replicates the effect so far. The actual example has lots of interconnected resolvers...

λustin f(n)21:02:48

I just noticed that the resolvers follow the 'correct' path that I expected it to, one that provides the missing field. But it only does this on the first resolution. The correct path is fairly slow, so I wonder if the path weighting algorithm is trying to get around resolving the slow resolver.

λustin f(n)21:02:22

Alright, I looked up how the weighting works. After noticing that "If a resolver call throws an exception, double it’s weight", I decided to change my resolver to throw an exception if any of the inputs are missing.

λustin f(n)21:02:08

This fixed the behavior, as pathom is now correctly falling back to the other path on failure, as well as discouraging the problem path somewhat.

λustin f(n)00:02:14

This is becoming problematic because this not found is happening even when there is an alternate path to get to the value I am asking for, but the 'composite' resolver is prioritized or something. Maybe I am simply modeling the data relationships incorrectly.


All inputs are required for resolvers until gets implemented. For the not-found issue, I strongly suggest using the com.wsscode.pathom.core/elide-special-outputs-plugin, that removes that from the final set. Your resolvers should never see that value.

Ben Grabow17:02:46

Can I get a little help understanding how to-many resolvers and queries are supposed to work? I'm trying to add pathom on top of the Lacinia tutorial project and I'm stuck on getting the board game -> designers query to work.

Ben Grabow17:02:13

I want to look up all the designer names for a given board game ID. Right now I'm getting a reader-error:

(a/<!! (parser {:database {:data (-> (io/resource "cgg-data.edn")
               [{[:board-game/id "1234"]
                  {:board-game/designers [:designer/name]}]}]))
{[:board-game/id "1234"] #:board-game{:designers :com.wsscode.pathom.core/reader-error},
 :com.wsscode.pathom.core/errors {[[:board-game/id "1234"] :board-game/designers] "class java.lang.IllegalArgumentException: find not supported on type: java.lang.String"}}

Ben Grabow17:02:17

I can make the board game id -> designer ids jump, and I can do the designer id -> designer name jump, but I must have something hooked up wrong or I'm misunderstanding how the designer ids -> designer id jump is supposed to work:

(a/<!! (parser {:database {:data (-> (io/resource "cgg-data.edn")
               [{[:board-game/id "1234"]
                {[:designer/id "200"]
=> {[:designer/id "200"] #:designer{:name "Kris Burm"}, [:board-game/id "1234"] #:board-game{:designers ("200")}}

Chris O’Donnell17:02:51

It looks to me like your board game resolver is returning {:board-game/designers ("200")} where it should be returning {:board-game/designers ({:designer/id "200"})}.

Ben Grabow17:02:19

Is there a way I can query for the designer names without knowing about the :board-game/designers key? I.e. I know that a board game has designers who have names, but I don't want to care about the implementation details of how that path gets traversed.

Ben Grabow18:02:13

Hmm, maybe I'm thinking about that wrong. If we imagine a schema where a board game has some designers who authored the game, and some other designers who advised the design, I would need to specify if I want to look up the names of the authoring designers vs looking up the names of the advising designers. So the relationship represented by :board-game/designers is a necessary part of the query specification.

Chris O’Donnell20:02:42

Right, that is what's connecting the board game with its set of designers, and that connection has to live somewhere. There are other ways to model it, but this one seems pretty natural to me. 👍