walmartlabs / lacinia

GraphQL implementation in pure Clojure
http://lacinia.readthedocs.io/en/latest/
Other
1.82k stars 160 forks source link

Passing in variables wrapped in an array comes in as a double array #434

Closed jantorestolsvik closed 1 year ago

jantorestolsvik commented 1 year ago

Hi, the following does not work as expected. The variable received in the resolver if $a is "a" is [["a"]] instead of ["a"] which I would expect.

mutation TestMutation (
  $a: String!
) {
  test_mutation(string_list: [$a]) {
   id 
  }
}
hlship commented 1 year ago

What is the schema for test_mutation in the above example?

hlship commented 1 year ago

Today's my day to work on open source; I'll see if I can reproduce this easily.

hlship commented 1 year ago

My first take on reproducing this didn't work:

(deftest vars-in-array-pass-thru-correctly
  ;; See https://github.com/walmartlabs/lacinia/issues/434
  (let [schema (schema/compile {:queries
                                {:echo
                                 {:type :String
                                  :args {:input {:type '(list String)}}
                                  :resolve (fn [_ args _]
                                             (pr-str args))}}})
        result (execute schema
                        "query ($s: String) {
                          echo (input: [$s])
                        }"
                        {:s "lacinia"}
                        nil)]
    (is (= {:data {:echo "{:input [\"lacinia\"]}"}}
           result))))

The above should fail if this bug is valid, but doesn't. Perhaps there's something more I'm missing.

hlship commented 1 year ago

Please re-open if you can come up with a test case.

jantorestolsvik commented 1 year ago

Thanks for looking into it. We are also using lacinia-pedestal, so I thought the error might be there then. I could not replicate it there either. I will check on our end if we are doing something weird with interceptors or something.