This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-07-12
Channels
- # announcements (2)
- # beginners (36)
- # boot (6)
- # calva (2)
- # cider (18)
- # clj-kondo (1)
- # cljdoc (2)
- # cljs-dev (2)
- # clojure (130)
- # clojure-boston (1)
- # clojure-brasil (3)
- # clojure-czech (1)
- # clojure-europe (11)
- # clojure-italy (4)
- # clojure-losangeles (37)
- # clojure-nl (9)
- # clojure-seattle (2)
- # clojure-sweden (8)
- # clojure-uk (23)
- # clojurescript (13)
- # core-async (21)
- # cursive (13)
- # data-science (6)
- # datomic (12)
- # emacs (36)
- # figwheel-main (9)
- # fulcro (76)
- # juxt (2)
- # keechma (18)
- # leiningen (4)
- # off-topic (13)
- # pedestal (37)
- # re-frame (21)
- # reitit (2)
- # shadow-cljs (78)
- # spacemacs (23)
- # sql (13)
- # tools-deps (25)
- # uncomplicate (4)
- # unrepl (1)
- # vim (27)
I’m going through the Fulcro tutorial. I just reached the step where a server handler is added to get some data from the server instead of doing everything locally (http://book.fulcrologic.com/#_implementing_the_server_handler). Has anybody done this tutorial recently? It says I should get an error when doing (df/load app :current-user root/Person)
from the client (which I don’t) and after adding ns app.api.read
with a defquery-root
it should show a network request/response with the user as a response. In the fulcro inspector I do see the request being done in the ‘network’ tab, but the response is empty. I did restart the server (and in fact everything). Any pointers? I can push my code somewhere if needed to understand my situation.
Looking a bit further, I now suspect that the tutorial is not up to date. The fulcro template is already using a pathom parser instead of the fulcro parser (`wrap-api` in middleware.clj
), but the tutorial assumes it’s using the fulcro parser. Is this causing defquery-root
to not work? Should I use some pathom-based way of defining the query handler?
Hi @stefan.van.den.oord! The tutorial is not up to date I’m afraid. You should be using Pathom to handle queries; Fulcro is moving away from using defquery-root
etc and fully embracing Pathom instead.
Right I suspected as much. Is there a simple change that I can do to get over this hump and proceed with the tutorial? (I mean without having to spend a few hours learning pathom while I’m learning fulcro :)
(ns app.api.read
(:require
[fulcro.server :refer [defquery-root defquery-entity defmutation]]))
(def people-db (atom {1 {:db/id 1 :person/name "Bert" :person/age 55 :person/relation :friend}
2 {:db/id 2 :person/name "Sally" :person/age 22 :person/relation :friend}
3 {:db/id 3 :person/name "Allie" :person/age 76 :person/relation :enemy}
4 {:db/id 4 :person/name "Zoe" :person/age 32 :person/relation :friend}
99 {:db/id 99 :person/name "Me" :person/role "admin"}}))
(defquery-root :current-user
"Queries for the current user and returns it to the client"
(value [env params]
(get @people-db 99)))
@stefan.van.den.oord my advice would be to start a project with the lein template and either use that or copy over the server stuff (which uses pathom) to your current project
Would you mind doing a liveshare with me? I don’t have much time now; it will be more efficient to help you this way
@stefan.van.den.oord how’s it going?
I’m finding the down-side of data-driven designs is that it’s hard to tell what’s really happening sometimes.
The nils are not coming from the network, I disabled all the loading on mounting and I still get an entry with nils. I renamed some keywords namespaces in the UI code, I think I messed up somewhere. I’ll just redo that, it’s a good learning experience 😉
Almost there 🙂 Got all users from the server in the “friends” list; now just add two resolvers for friends and enemies and load those into the corresponding lists.
Hmm, strange: If I name my resolver friends
and have it return a map {:friends ...}
, it doesn’t load the data correctly in the UI, but if I name it all-friends
and return a map {:all-friends ...}
it works. Maybe it doesn’t process the data correctly with my target
specification?
(df/load app :all-friends root/Person
{:target [:person-list/by-id :friends :person-list/people]})
@stefan.van.den.oord yeah, I need to take down the tutorial…it is way out of date, and thre is a getting started chapter in the book, so it is largely irrelevant now
I thought you meant you were following : http://fulcro.fulcrologic.com/tutorial.html
ok, so it’s just that the getting started bits assume the template is different than it is?
The book doesn’t take phantom into account. In the fulcro template that’s the default now.
(And I also created a pull request today: https://github.com/fulcrologic/fulcro/pull/318)
So, the new book is http://book.fulcrologic.com/fulcro3 but it is out of date later in the book, and requires you use alpha versions of fulcro
that is a better approach for correctness because it does not use such a moving target (the template)
just beware that I’m actively working on that book, and minor things may still change in the lib
not a complete redo from start, but a lot of things got significant internal improvements