                              :user/favorite-number 42
                              :user/favorite-fellow-user {:user/name "jburnford"
                                                          :user/favorite-color :color/red
-                                                         :user/favorite-number 7}}}
+                                                         :user/favorite-number 7}}
+                 :jamie {:user/name "jburnford"
+                         :user/favorite-color :color/red}}
                 v))
          (is (= [[:get-user {:name "nipponfarm"}]
                  [:get-user {:name "jburnford"}]]


   #{:user/favorite-color :user/favorite-number}
   (fn [context ast]
     (let [get-user (get-in context [:apis :get-user])]
       (p/map
        #(set/rename-keys % {:favorite-color :user/favorite-color
                             :favorite-number :user/favorite-number})
        (get-user {:name (:user/name context)}))))

   :user/favorite-fellow-user
   (fn [context ast]
     (let [get-user (get-in context [:apis :get-user])
           user-promise (get-user {:name (:user/name context)})]
       (p/then user-promise
               (fn [user]
                 (resolve* (assoc context :user/name (:favorite-fellow-user-name user))
                           User
                           (:children ast))))))})


(def Root



(defn resolve* [context mapping children]
  (p/alet [values
           (p/await
            (p/all
             (for [ast children
                   :let [read-from-key (get-in ast [:params :<] (:key ast))]]
               (if (contains? mapping read-from-key)
                 (let [resolver (get mapping read-from-key)]
                   (resolver context ast))
                 (if-let [[keys resolver]
                          (first (filter #(contains? (key %) read-from-key) mapping))]
                   (p/then (resolver context ast) #(get % read-from-key))
                   (throw "Unknown key"))))))]
    (into {}
          (map #(vector (:key %1) %2)
               children values))))


(defn resolve [context root-mapping query]
