This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-04-20
Channels
- # aws-lambda (8)
- # beginners (37)
- # cider (43)
- # cljs-dev (12)
- # clojure (121)
- # clojure-italy (19)
- # clojure-nl (1)
- # clojure-poland (1)
- # clojure-russia (14)
- # clojure-spec (6)
- # clojure-uk (98)
- # clojurescript (28)
- # core-async (1)
- # cursive (7)
- # datomic (4)
- # emacs (63)
- # events (8)
- # fulcro (19)
- # graphql (4)
- # hoplon (3)
- # mount (1)
- # nrepl (101)
- # off-topic (15)
- # om (3)
- # pedestal (2)
- # portkey (31)
- # protorepl (2)
- # re-frame (26)
- # reagent (26)
- # reitit (2)
- # shadow-cljs (58)
- # spacemacs (8)
- # specter (5)
- # sql (56)
- # test-check (11)
- # tools-deps (48)
- # vim (52)
I came up with this spec. Might be a start.
(s/def ::ident (s/and vector? (s/tuple keyword? #(not (coll? %)))))
(s/def ::join-key (s/or :prop keyword? :ident ::ident))
(s/def ::join (s/map-of ::join-key ::query :conform-keys true))
(s/def ::union (s/map-of keyword? (s/map-of keyword? ::query)))
(s/def ::param-expr
(s/cat :query-expr ::query-expr
:params map?))
(s/def ::mutation-expr
(s/or :no-params (s/cat :mutate-key symbol?)
:with-params (s/cat :mutate-key symbol?
:params map?)))
(s/def ::query-expr
(s/or :prop keyword?
:ident ::ident
:mutation-expr ::mutation-expr
:union ::union
:join ::join
:param-expr ::param-expr))
(defn query-conform [x]
(if (vector? x) x :clojure.spec/invalid))
(s/def ::query
(s/or :recursion (s/or :depth number?
:unbounded #(= % '...))
:query (s/and (s/conformer query-conform vec)
(s/+ ::query-expr))))
👍 4
@danielstockton @souenzzo there is a fully working spec and generators available in pathom: https://github.com/wilkerlucio/pathom/blob/master/src/com/wsscode/pathom/specs/query.cljc
😎 4