This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-08-22
Channels
- # aws (12)
- # babashka (24)
- # beginners (51)
- # biff (2)
- # cherry (4)
- # cider (2)
- # clj-kondo (4)
- # cljs-dev (19)
- # clojure (70)
- # clojure-australia (4)
- # clojure-europe (39)
- # clojure-nl (4)
- # clojure-norway (6)
- # clojure-spec (9)
- # clojurescript (21)
- # component (6)
- # cursive (18)
- # data-science (9)
- # datomic (18)
- # events (2)
- # expound (4)
- # fulcro (15)
- # graalvm (2)
- # graphql (5)
- # jobs (1)
- # juxt (2)
- # leiningen (8)
- # malli (4)
- # meander (21)
- # nrepl (3)
- # observability (14)
- # off-topic (49)
- # other-languages (1)
- # pathom (13)
- # pedestal (7)
- # rdf (5)
- # re-frame (10)
- # reitit (1)
- # sql (4)
- # squint (30)
- # tools-deps (1)
- # vim (11)
Sorry if this is a basic question, but I can't figure out how to return an error response through an EQL endpoint for queries that refer to an entity id that doesn't exist. If I query for
[{[:person/id "non-existing-id"]
[:person/id :person/name]}]
I will obtain
{[:person/id "non-existing-id"]
{:person/id "non-existing-id"}}
as my resolver for person/name
is returning nil
.
My Fulcro client application doesn't obtain the value for the person-name
attribute, but it is believing that there is a person with id "non-existing-id".hello @U015KAUQRFE, welcome 🙂 not at all, its a difference in mindset around modeling information. in a standard entity based its common have this notion of if an entity exists or not (like: is there a row for it in the database?), but in Pathom, using attribute modeling, the question becomes a bit more complex, because there is no notion of the entity as a single thing, instead its about attribute reachability
in this world, what you can do, is define some attribute to tell you specifically that (like: :person/exists-in-db?
), make an attribute to do that check (directly going to the db, or depending on something else that you always expect present for a user stored in db), makes sense?
That doesn't solve the issue, because that would involve client code making sure that every request contains the additional attribute, and I guess would need to override Fulcro defaults in order to introduce code checks when receiving the response.
For now, I have removed the error-handler-plugin
that the Fulcro tutorial adds to the Pathom config, and I'm throwing an exception from the resolver.
hi yall
let’s say I have a resolver that depends on 2 inputs a
and b
and returns c
(let’s say it’s the sum of those)
how can I write an EQL query to express those two values given that ident is [:a 1]
or [:b 2]
Cannot seem to find anything on docs…
cheers
Are a
and b
global resolvers that resolve without input? If so, write a resolver that takes both of those as inputs and outputs c
, which is their sum, and then just request [:c]
:
::pco/input [:a :b]
::pco/output [:c]
Or perhaps you're thinking about it more like parameters? In that case you pass them in using EQL params ['(:c {:a 1 :b 2})]
.
If :a
and :b
aren't global, meaning that they require some input to retrieve, you have to provide as much data as is necessary in order get them, and then you can get c
.
Remember that the planner has a single entry point, but attributes which can be resolved without inputs an be retrieved at any place in the graph.
Does that help?[{[:a 1] [:c]}]
<- how do I get the :b
in there in order to get :c 2
(pco/defresolver b
[]
{:b 2})
(pco/defresolver c
[{:keys [a b]}]
{:c (+ a b)})
(p.eql/process (pci/register [ b c])
[{[:a 1] [:c]}])
; => {[:a 1] {:c 3}}
When using EQL idents to provide data you are providing a single attribute to start from.
in Pathom 3, the best way is to send an entity data, so you can query strait from the root, like: (p.eql/process env {:a 1 :b 2} [:c])
when using the boundary interface, you can also make a request like:
(request {:pathom/entity {:a 1 :b 2} :pathom/tx [:c]})
but if you need to send via query (maybe to have multiple things) you can do: [{(:>/foo {:a 1 :b 2}) [:c]}]
, but I might break this interface because I found some usages that make this "always use placeholder params as entity data" is problematic for some use cases
cheers!