                 oir)))
       (dissoc ::pc/index-source-id)))
 
+(defn internalize-remote-index-by-service [{::pc/keys [index-source-id] :as indexes}]
+  (let [sources (atom #{})]
+    (-> indexes
+        (update ::pc/index-resolvers
+          (fn [resolvers]
+            (into {}
+                  (map (fn [[r v]]
+                         (if-let [resolver-source (some-> v :abrams.diplomat.api/service symbol)]
+                           (do
+                             (swap! sources conj resolver-source)
+                             [r (assoc v ::pc/source-resolver resolver-source)])
+                           [r v]
+                           #_[r (assoc v ::pc/source-resolver index-source-id)])))
+                  resolvers)))
+        (as-> <>
+          (reduce
+            (fn [indexes source]
+              (assoc-in indexes [::pc/index-resolvers source]
+                {::pc/sym               source
+                 ::pc/cache?            false
+                 ::pc/dynamic-resolver? true
+                 ::pc/resolve           (fn [_ _] (println "CALL REMOTE"))}))
+            <>
+            @sources))
+        (update ::pc/index-oir
+          (fn [oir]
+            (into {}
+                  (map (fn [[attr paths]]
+                         [attr
+                          (into {}
+                                (map (fn [[inputs resolvers]]
+                                       [inputs
+                                        (into
+                                          #{}
+                                          (map (fn [sym]
+                                                 (or (some-> (get-in indexes [::pc/index-resolvers sym :abrams.diplomat.api/service])
+                                                             symbol)
+                                                     sym)))
+                                          resolvers)]))
+                                paths)]))
+                  oir)))
+        (dissoc ::pc/index-source-id))))
+
 (comment
   (compute-run-graph
     (-> {::eql/query           [:customer/id :customer/name :customer/dob

         ::pcrg/available-data {:customer/id {}}
         ::render-graphviz?    true
         ::time?               true}
        (pc/merge-indexes index))))

     :com.wsscode.pathom.connect/index-resolvers
     :com.wsscode.pathom.connect/index-mutations]}]

  (do
    (def internal-index
      (-> (slurp (str (System/getenv "HOME") "/index.edn"))
          (edn/read-string)
          (assoc ::pc/index-source-id 'dynamic-source)
          internalize-remote-index))

    (def internal-index-by-service
      (-> (slurp (str (System/getenv "HOME") "/index.edn"))
          (edn/read-string)
          (assoc ::pc/index-source-id 'dynamic-source)
          internalize-remote-index-by-service))

    (def index
      (-> (slurp (str (System/getenv "HOME") "/index.edn"))
          (edn/read-string)
          (assoc ::pc/index-source-id 'dynamic-source)))

    (defn stored-query [path]
      (-> (slurp (str (System/getenv "HOME") "/queries/" path))
          (edn/read-string))))

  (::pc/index-resolvers internal-index-by-service)

  (time
    (compute-run-graph
