Fork me on GitHub
#graphql
<
2021-05-23
>
steveb8n05:05:34

Q: namespaced keyword are idiomatic in Clojure but not in graphql. Currently I discard namespaces when exposing a graphql api. how are others exposing namespaces (if at all) and what have you learned from your choice?

fmnoise16:05:10

something like that

:Keyword {:description "The Keyword scalar type represents valid Clojure keyword eg \"user.role/admin\""
           :parse keyword
           :serialize (fn [k]
                        (when (keyword? k)
                          (let [ns (namespace k)
                                name (name k)]
                            (if ns (str ns "/" name) name))))}

fmnoise16:05:22

it definitely works, but I feel like using enums is better for keeping constraints and reducing garbage input