Created
March 19, 2019 19:29
-
-
Save codonnell/34b685f57e3262a2cc9853d4a15a771f to your computer and use it in GitHub Desktop.
POC Fulcro GraphQL Snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(fp/defsc GiftList | |
[this {:gql.gift/keys [id name]}] | |
{:ident [:gql.gift/id :gql.gift/id] | |
:query [:gql.gift/id :gql.gift/name]} | |
(js/console.log {:gift [id name]}) | |
(dom/div "Gift list " id ": " name)) | |
(def ui-gift-list (fp/factory GiftList {:keyfn :gql.gift/id})) | |
(fp/defsc GiftListDemo | |
[this {:gql/keys [gift]}] | |
{:initial-state (fn [_] {}) | |
:ident (fn [] [::root "singleton"]) | |
:query [{:gql/gift (fp/get-query GiftList)}]} | |
(js/console.log {:props (fp/props this)}) | |
(dom/div (mapv ui-gift-list gift))) | |
(def ui-gift-list-demo (fp/factory GiftListDemo)) | |
(defonce SPA (atom nil)) | |
(defn mount [] | |
(reset! SPA (fc/mount @SPA GiftListDemo "app"))) | |
(defn start [] | |
(mount)) | |
(defn ^:export init [] | |
(reset! SPA (fc/new-fulcro-client | |
:started-callback | |
(fn [app] | |
(go-catch | |
(try | |
(<? gift-list-index-status) | |
(df/load app [::root "singleton"] GiftListDemo) | |
(catch :default e (js/console.error "Error making index" e))))) | |
:networking | |
{:remote (-> parser | |
pfn/pathom-remote | |
pfn/trace-remote)})) | |
(start)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment