Resolve some warnings in the tests
2 files changed, 48 insertions(+), 51 deletions(-)

M src/execution.lisp
M t/execution-tests.lisp
M src/execution.lisp +1 -0
@@ 167,6 167,7 @@ 
           (cond
             (;; including 'null' as a default value
              (and (null has-value-p) default-value)
+             ;; TODO: Check if we can properly identify 'null here
              (setf (gethash argument-name coerced-values) default-value))
             ((and (eq (kind argument-type) 'non-null-type)
                   (or (null has-value-p)

          
M t/execution-tests.lisp +47 -51
@@ 225,15 225,13 @@ 
       ((owner :initarg :owner :accessor owner)
        (nickname :initarg :nickname :accessor nickname)))
 
-    (defparameter *doggo*
-      (make-instance 'dog :name "Bingo-Bongo" :type-name "Dog"))
-
-    (with-schema (build-schema (asdf:system-relative-pathname 'gql-tests #p"t/test-files/validation-schema.graphql"))
-      ;; We want to know if we did get the actual same reference.
-      (ok (eq (gql::resolve-abstract-type (gethash "CatOrDog" gql::*all-types*) *doggo*)
-              (gethash "Dog" gql::*all-types*)))
-      (ok (eq (gql::resolve-abstract-type (gethash "Pet" gql::*all-types*) *doggo*)
-              (gethash "Dog" gql::*all-types*))))))
+    (let ((doggo (make-instance 'dog :name "Bingo-Bongo" :type-name "Dog")))
+      (with-schema (build-schema (asdf:system-relative-pathname 'gql-tests #p"t/test-files/validation-schema.graphql"))
+        ;; We want to know if we did get the actual same reference.
+        (ok (eq (gql::resolve-abstract-type (gethash "CatOrDog" gql::*all-types*) doggo)
+                (gethash "Dog" gql::*all-types*)))
+        (ok (eq (gql::resolve-abstract-type (gethash "Pet" gql::*all-types*) doggo)
+                (gethash "Dog" gql::*all-types*)))))))
 
 (deftest doggo-test
   (testing "Doggo-testing"

          
@@ 274,50 272,48 @@ 
                          :nickname "Mjausig"
                          :type-name "Cat")))))
 
-    (defparameter *query-resolvers*
-      (let ((ht (make-hash-table :test #'equal)))
-        (setf (gethash "dog" ht)
-              (lambda (arg) (declare (ignorable arg)) *doggo*))
-        ht))
+    (let* ((query-resolvers
+             (let ((ht (make-hash-table :test #'equal)))
+               (setf (gethash "dog" ht)
+                     (lambda (arg) (declare (ignorable arg)) *doggo*))
+               ht))
 
-    (defparameter *dog-resolvers*
-      (let ((ht (make-hash-table :test #'equal)))
-        (setf (gethash "name" ht) (lambda (dog) (name dog)))
-        (setf (gethash "nickname" ht) (lambda (dog) (nickname dog)))
-        (setf (gethash "owner" ht) (lambda (dog) (owner dog)))
-        ht))
+           (dog-resolvers
+             (let ((ht (make-hash-table :test #'equal)))
+               (setf (gethash "name" ht) (lambda (dog) (name dog)))
+               (setf (gethash "nickname" ht) (lambda (dog) (nickname dog)))
+               (setf (gethash "owner" ht) (lambda (dog) (owner dog)))
+               ht))
 
-    (defparameter *cat-resolvers*
-      (let ((ht (make-hash-table :test #'equal)))
-        (setf (gethash "name" ht) (lambda (cat) (name cat)))
-        (setf (gethash "nickname" ht) (lambda (cat) (nickname cat)))
-        (setf (gethash "owner" ht) (lambda (cat) (owner cat)))
-        ht))
+           (cat-resolvers
+             (let ((ht (make-hash-table :test #'equal)))
+               (setf (gethash "name" ht) (lambda (cat) (name cat)))
+               (setf (gethash "nickname" ht) (lambda (cat) (nickname cat)))
+               (setf (gethash "owner" ht) (lambda (cat) (owner cat)))
+               ht))
 
-    (defparameter *human-resolvers*
-      (let ((ht (make-hash-table :test #'equal)))
-        (setf (gethash "name" ht) (lambda (human) (name human)))
-        (setf (gethash "pets" ht) (lambda (human) (pets human)))
-        ht))
-
-    (flet ((doggo-test (query)
-             (with-schema (build-schema (asdf:system-relative-pathname 'gql-tests #p"t/test-files/validation-schema.graphql"))
-               (let* ((res (gql::execute-request
-                            (build-schema query) nil (make-hash-table :test #'equal) nil)))
-                 (format nil "~a" (cl-json:encode-json-to-string res))))))
+           (human-resolvers
+             (let ((ht (make-hash-table :test #'equal)))
+               (setf (gethash "name" ht) (lambda (human) (name human)))
+               (setf (gethash "pets" ht) (lambda (human) (pets human)))
+               ht))
+           (*resolvers*
+             (let ((ht (make-hash-table :test #'equal)))
+               (setf (gethash "Query" ht) query-resolvers)
+               (setf (gethash "Dog" ht) dog-resolvers)
+               (setf (gethash "Cat" ht) cat-resolvers)
+               (setf (gethash "Human" ht) human-resolvers)
+               ht)))
 
-      (let ((*resolvers* (make-hash-table :test #'equal)))
-        (setf (gethash "Query" *resolvers*) *query-resolvers*)
-        (setf (gethash "Dog" *resolvers*) *dog-resolvers*)
-        (setf (gethash "Cat" *resolvers*) *cat-resolvers*)
-        (setf (gethash "Human" *resolvers*) *human-resolvers*)
-        (let ((result (doggo-test "query { dog { name owner { name pets { name nickname } } } }")))
-          (ok (string= result "{\"data\":{\"dog\":{\"name\":\"Bingo-Bongo\",\"owner\":{\"name\":\"Wingle Wangle\",\"pets\":[{\"name\":\"Bingo-Bongo\",\"nickname\":\"Hund!\"},{\"name\":\"Bango-Wango\",\"nickname\":\"Mjausig\"}]}}},\"errors\":null}"))))
+      (flet ((doggo-test (query)
+               (with-schema (build-schema (asdf:system-relative-pathname 'gql-tests #p"t/test-files/validation-schema.graphql"))
+                 (let* ((res (gql::execute-request (build-schema query) nil (make-hash-table :test #'equal) nil)))
+                   (format nil "~a" (cl-json:encode-json-to-string res))))))
 
-      (let ((*resolvers* (make-hash-table :test #'equal)))
-        (setf (gethash "Query" *resolvers*) *query-resolvers*)
-        (setf (gethash "Dog" *resolvers*) *dog-resolvers*)
-        (setf (gethash "Cat" *resolvers*) *cat-resolvers*)
-        (setf (gethash "Human" *resolvers*) *human-resolvers*)
-        (let ((result (doggo-test "query { dog: doggo { name: Bingo owner { name: Wingle pets: dogs { name nickname: thisIsFun } } } }")))
-          (ok (string= result "{\"data\":{\"doggo\":{\"Bingo\":\"Bingo-Bongo\",\"owner\":{\"Wingle\":\"Wingle Wangle\",\"dogs\":[{\"name\":\"Bingo-Bongo\",\"thisIsFun\":\"Hund!\"},{\"name\":\"Bango-Wango\",\"thisIsFun\":\"Mjausig\"}]}}},\"errors\":null}")))))))
+        (ok (string=
+             (doggo-test "query { dog { name owner { name pets { name nickname } } } }")
+             "{\"data\":{\"dog\":{\"name\":\"Bingo-Bongo\",\"owner\":{\"name\":\"Wingle Wangle\",\"pets\":[{\"name\":\"Bingo-Bongo\",\"nickname\":\"Hund!\"},{\"name\":\"Bango-Wango\",\"nickname\":\"Mjausig\"}]}}},\"errors\":null}"))
+
+        (ok (string=
+             (doggo-test "query { dog: doggo { name: Bingo owner { name: Wingle pets: dogs { name nickname: thisIsFun } } } }")
+             "{\"data\":{\"doggo\":{\"Bingo\":\"Bingo-Bongo\",\"owner\":{\"Wingle\":\"Wingle Wangle\",\"dogs\":[{\"name\":\"Bingo-Bongo\",\"thisIsFun\":\"Hund!\"},{\"name\":\"Bango-Wango\",\"thisIsFun\":\"Mjausig\"}]}}},\"errors\":null}"))))))