-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
transit.cljc
22 lines (19 loc) · 840 Bytes
/
transit.cljc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(ns com.wsscode.pathom3.connect.operation.transit
(:require
[cognitect.transit :as t]
[com.wsscode.pathom3.connect.operation
#?@(:cljs [:refer [Resolver Mutation]])
:as pco])
#?(:clj
(:import
(com.wsscode.pathom3.connect.operation
Mutation
Resolver))))
(defn restored-handler [_ _]
(throw (ex-info "This operation came serialized via transit, it doesn't have an implementation." {})))
(def read-handlers
{"pathom3/Resolver" (t/read-handler #(-> % (assoc ::pco/resolve restored-handler) pco/resolver))
"pathom3/Mutation" (t/read-handler #(-> % (assoc ::pco/mutate restored-handler) pco/mutation))})
(def write-handlers
{Resolver (t/write-handler (fn [_] "pathom3/Resolver") pco/operation-config)
Mutation (t/write-handler (fn [_] "pathom3/Mutation") pco/operation-config)})