retro / graphql-builder

GraphQL client library for Clojure and ClojureScript
MIT License
184 stars 15 forks source link

enums not supported #8

Closed emilssolmanis closed 4 years ago

emilssolmanis commented 6 years ago

Hi

Looks like enum args are not supported right now, i.e.,

(def derp
  "
  query Foo {
    productList(someArg: moo, otherArg: \"DESC\") {
      name
    }
  }
")

(deftest hurr-durr
  (let [query-map (core/query-map (parse derp) {})
        query-fn (get-in query-map [:query :foo])]
    (is (= (str/trim derp)
           (get-in (query-fn) [:graphql :query])))))

this fails. I did some digging, and by the looks of it this is literally unfixable without moving to the 0.2.x series of the parser, because as is you only get

{:node-type :field,
 :field-name "productList",
 :arguments [{:node-type :argument,
                       :argument-name "someArg",
                       :value "moo"},
                       ...

versus 0.2.x being

:tag :selection-field,
:name productList,
:arguments [{:tag :argument,
                      :name someArg,
                      :value {:tag :enum-value, :image "moo", :value moo}}
...

I.e., you wouldn't even know if it's an enum value or a string with the current parser.

retro commented 6 years ago

@emilssolmanis I'm using ENUM values as strings without any issues, both on JavaScript and Elixir backends. Did you try that?

Also, I'm planning the move to 0.2 parser version, but the internals have a lot of changes, so it will be more rewrite than upgrade

emilssolmanis commented 6 years ago

@retro it fails with a validation error in my case, the backend is in node, not sure of the specific framework. I'm aware it's more of a rewrite.

retro commented 6 years ago

@emilssolmanis Can you please try just one more thing, can you try to pass the someArg as a variable? Maybe that's the difference.

retro commented 4 years ago

Fixed in 0.1.9 5a928e514f5d2335cc98df0ae6569e0fe2df7d9a