Fork me on GitHub
#graphql
<
2022-11-21
>
orestis06:11:53

Disregard please, something was messed up in my REPL. I even forked Lacinia to add a new test, but it's already passing. Pasting here if it's helpful to add:

(deftest external-fragments
  (testing "when @skip is set on an external fragment"
    (let [q "
             fragment IdFrag on human {
               id @skip(if: $skip)
             }
             query ($skip : Boolean!) {
               human(id: \"1000\") {
                 name
                 ... IdFrag
               }
             }
             "]
      (is (= {:data {:human {:name "Luke Skywalker"}}}
             (execute compiled-schema q {:skip true} nil))
          "should return name only")
      (is (= {:data {:human {:name "Luke Skywalker"
                             :id "1000"}}}
             (execute compiled-schema q {:skip false} nil))
          "should return both fields")))

  (testing "when @include is set on an external fragment"
    (let [q "fragment IdFrag on human {
               id @include(if: $include)
             }

             query ($include : Boolean!) {
               human(id: \"1000\") {
                 name
                 ... IdFrag
               }
             }"]
      (is (= {:data {:human {:name "Luke Skywalker"}}}
             (execute compiled-schema q {:include false} nil))
          "should return name only")
      (is (= {:data {:human {:name "Luke Skywalker"
                             :id "1000"}}}
             (execute compiled-schema q {:include true} nil))
          "should return both fields"))))

orestis10:11:02

In directives_test.clj