When passing a sequence to the graphql-query function this leads to different behaviour whether the sequence is a ChunkedSeq or an IndexedSeq.
Example
(require '[graphql-query.core :refer [graphql-query]])
(def indexed-seq
(seq (mapv (comp keyword str) (take 10 (range)))))
;; => (:0 :1 :2 :3 :4 :5 :6 :7 :8 :9)
(type indexed-seq)
;; => cljs.core/IndexedSeq
(graphql-query
{:queries [[:foo {:bar indexed-seq}]]})
;; => "{foo(bar:[0,1,2,3,4,5,6,7,8,9])}"
(def chunked-seq
(seq (mapv (comp keyword str) (take 40 (range)))))
;; => (:0 :1 :2 :3 :4 :5 :6 :7 :8 :9 :10 ... :39)
(type chunked-seq)
;; => cljs.core/ChunkedSeq
(graphql-query
{:queries [[:foo {:bar chunked-seq}]]})
;; => "{foo(bar:(:0 :1 :2 :3 :4 :5 :6 :7 :8 :9 :10 ... :39))}"
So when the sequence is longer and thus Clojure internally handles it as a ChunkedSeq instead of an IndexedSeq, the collection in the arguments is processed to become a list with keywords, instead of a vector with symbols. In the ChunkedSeq case the query generated is invalid GraphQL.
Workaround
Ensure the sequence passed to graphql-query is not of type ChunkedSeq, for example by marshalling the sequence into a vector.
When passing a sequence to the
graphql-queryfunction this leads to different behaviour whether the sequence is aChunkedSeqor anIndexedSeq.Example
So when the sequence is longer and thus Clojure internally handles it as a
ChunkedSeqinstead of anIndexedSeq, the collection in the arguments is processed to become a list with keywords, instead of a vector with symbols. In theChunkedSeqcase the query generated is invalid GraphQL.Workaround
Ensure the sequence passed to
graphql-queryis not of typeChunkedSeq, for example by marshalling the sequence into a vector.