graphql updates.

This commit is contained in:
Bryce Covert
2018-04-12 13:13:11 -07:00
parent 7425f7f393
commit 812292b5aa
4 changed files with 39 additions and 21 deletions

View File

@@ -19,10 +19,11 @@
{:db (assoc db/default-db
:active-page handler
:user token)
:http {:method :get
:token token
:uri (str "/api/companies")
:on-success [::received-companies]}}))))
:graphql {:token token
:query-obj {:venia/queries [[:company
[:id :name]]]}
:on-success [::received-companies]}}))))
(re-frame/reg-event-db
::toggle-menu
@@ -32,15 +33,16 @@
(re-frame/reg-event-fx
::logged-in
(fn [{:keys [db]} [_ token user]]
{:http {:method :get
:token token
:uri (str "/api/companies")
:on-success [::received-companies]}
{:graphql {:token token
:query-obj {:venia/queries [[:company
[:id :name]]]}
:on-success [::received-companies]}
:db (assoc db :user (assoc user :token token))}))
(re-frame/reg-event-db
::received-companies
(fn [db [_ companies]]
(fn [db [_ {companies :company}]]
(assoc db :companies (reduce (fn [companies company]
(assoc companies (:id company) company))
@@ -50,6 +52,7 @@
(re-frame/reg-event-db
::swap-company
(fn [db [_ company]]
(println company)
(assoc db :company (:id company))))
(re-frame/reg-event-fx