Skip to content

Instantly share code, notes, and snippets.

@ivarref
Created January 21, 2022 10:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivarref/41d4914b1ec3936ad83e0ed9a9c8517d to your computer and use it in GitHub Desktop.
Save ivarref/41d4914b1ec3936ad83e0ed9a9c8517d to your computer and use it in GitHub Desktop.
(defn iterate-gql-connection [{:keys [api-url token]} query variables]
(->> (iteration
(fn [after]
(some->> (client/post api-url {:content-type :json
:accept :json
:as :json
:headers {"authorization" (str "Bearer " token)}
:form-params {:query query
:variables (merge variables {:after after})}})
:body
:data
(vals)
(first)
:edges))
:some? not-empty
:vf (partial map :node)
:kf (comp :cursor last)
:initk nil)
(mapcat identity)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment