Skip to content

Instantly share code, notes, and snippets.

@dkozma
Created January 9, 2018 20:59
Show Gist options
  • Save dkozma/dcde614da4e468d912c18fb96d02455f to your computer and use it in GitHub Desktop.
Save dkozma/dcde614da4e468d912c18fb96d02455f to your computer and use it in GitHub Desktop.
Reagent-Apollo Sample Syntax
(: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