           :else (assert nil (format "Unhandled type kind for type: %s" type)))))))
 
 (defn field-kind [field]
-  (assert (:tag field) (format "field tag is nil for type: %s" field))
-  (assert (:name field) (format "field name is nil for type: %s" field))
   (let [tag (:tag field)
         name (:name field)
         type (:type field)]
+    (assert tag (format "field tag is nil for type: %s" field))
+    (assert name (format "field name is nil for type: %s" field))
     (cond
       (= :type-field tag) (type-kind type)
       :else (throw (ex-info (format "unknown field kind for field: %s" field) {:field field})))))

                      (get-in field [:type :name]))
        type (:type field)
        kind (field-kind field)
        inner-type (get-in field [:type :inner-type])]
    (assert kind (format "field kind is nil for field: %s" field))
    (if (#{:LIST} kind)
      (assert inner-type (format "field inner-type is nil for field: %s" field)))
    (assert (or type-name inner-type) (format "field type-name and inner-type are both nil for field: %s" field))
    (if (= :NON_NULL kind)
      {:kind kind
       :inner-type (dissoc type :required)}
      {:name (:name field)
       :description (:description field)
       :args (:arguments field) ; defer resolving of arguments
       
       ;; :type nil ; defer resolving of type
       :type-name type-name
       :kind kind
       :inner-type inner-type
       :required (:required field)
       
       :isDeprecated false ; TODO
       :deprecationReason nil ; TODO
       })))

(defn type-resolver [type]
  (let [kind (type-kind type)

  (let [type (:type arg)
        type-name (:name type)
        kind (type-kind (:type arg))
        inner-type (or (get-in arg [:type :inner-type])
                       (if (= :NON_NULL kind)
                         (dissoc type :required)))]
    (assert kind (format "argument kind is nil for: %s" arg))
    (when (#{:LIST} kind)
      (assert inner-type (format "inner-type is nil for type: %s" arg)))
    (assert (or type-name inner-type) (format "Both type-name and inner-type are nil for arg:%s" arg))
    (println "args-resolver: arg:" arg)
    {:name (:name arg)
     :description (:description arg)
     
     ;; defer resolving of type for argument
     :type-name type-name
     :kind kind
     :inner-type inner-type
     :required (:required arg)
     
     :defaultValue (:default-value arg)}))
