Created
January 9, 2018 20:59
-
-
Save dkozma/dcde614da4e468d912c18fb96d02455f to your computer and use it in GitHub Desktop.
Reagent-Apollo Sample Syntax
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
(:require [reagent-apollo.core :as a]) | |
(a/component "{ | |
feed(type: TOP, limit: 10) { | |
repository { | |
name | |
owner { login } | |
} | |
postedBy { login } | |
}" | |
(fn [props] | |
[:List | |
(let [items (get-in props [:data :feed])] | |
(doall | |
(for [item items] | |
[:ListItem {:title (str (get-in item [:repository :owner :login]) | |
(get-in item [:repository :name])) | |
:subtitle (str "Posted by" | |
(get-in item [:posted-by :login]))}])))])) | |
(defn- handle-click [props _] | |
(->> {:variables {:repo-full-name "apollographql/apollo-client"}} | |
(a/mutate props))) | |
(a/component | |
"mutation submitRepository($repoFullName: String!) { | |
submitRepository(repoFullName: $repoFullName) { | |
createdAt | |
} | |
}" | |
(fn [props] | |
[:button {:on-click (partial handle-click props)} | |
"Click me"])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment