             [com.wsscode.pathom.test-helpers :as th]
             [com.wsscode.pathom.misc :as p.misc]
             [clojure.core.async :as async :refer [go]]))
+
+(defn index-query? [tx]
+  (try
+    (= (first (ffirst tx)) ::pc/indexes)
+    (catch #?(:clj Throwable :cljs :default) _ false)))
 
 (defn run-parser [{::keys [resolvers query entity foreign error-stack? plugins]}]
   (let [foreign-calls (atom {})

                                                             {::p/wrap-parser
                                                              (fn [parser]
                                                                (fn [env tx]
                                                                  (if (= tx [:critical-error])
                                                                    (throw (ex-info "Parser Error" {:foo "bar"})))
                                                                  (swap! foreign-calls update source-id p.misc/vconj tx)
                                                                  (parser env tx)))}))}


      (testing "fatal error on remote parser"
        (is (= (run-parser
                 {::foreign [{::foreign-id   'remote
                              ::resolvers    [(pc/resolver 'a
                                                {::pc/output [:critical-error]}
                                                (fn [_ _] {:critical-error 4}))]
                              ::fatal-error? true}]
                  ::query   [:critical-error]})
               {:critical-error                 :com.wsscode.pathom.core/reader-error,
                :com.wsscode.pathom.core/errors {[:critical-error] "class clojure.lang.ExceptionInfo: Parser Error - {:foo \"bar\"}"}}))

        (testing "in ident request"
          (is (= (run-parser
                   {::foreign [{::foreign-id   'remote
                                ::resolvers    [(pc/resolver 'a
                                                  {::pc/input  #{:id}
                                                   ::pc/output [:critical-error]}
                                                  (fn [_ _] {:critical-error 4}))]
                                ::fatal-error? true}]
                    ::query   [{[:id 123] [:critical-error]}]})
                 {[:id 123]                       {:critical-error :com.wsscode.pathom.core/reader-error},
                  :com.wsscode.pathom.core/errors {[[:id 123] :critical-error] "class clojure.lang.ExceptionInfo: Parser Error - {:foo \"bar\"}"}})))))

    (testing "nested queries"
      (is (= (run-parser
