-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpathom_graphql_test.cljs
86 lines (74 loc) · 2.81 KB
/
pathom_graphql_test.cljs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
(ns revert.pathom-graphql-test
(:require
[cljs.pprint :as pprint]
[com.wsscode.pathom3.connect.planner :as pcp]
[com.wsscode.pathom3.connect.built-in.resolvers :as pbir]
[com.wsscode.pathom3.connect.indexes :as pci]
[com.wsscode.pathom3.graphql :as p.gql]
[com.wsscode.pathom3.interface.async.eql :as p.eql]
[promesa.core :as p]))
;;;; staker
;;
;;
;;
(defn request-subgraph
[query url]
(p/let [headers #js {"Content-Type" "application/json"
"Accept" "*/*"}
body (js/JSON.stringify (clj->js {:query query}))
resp (js/fetch url #js {:method "POST"
:headers headers
:body body})
js-data (.json resp)]
(js->clj js-data)))
(def env (-> {::pcp/experimental-branch-optimizations true}
(pci/register
[(pbir/equivalence-resolver :staker.Incentive/rewardToken :univ3.Token/id)])
(p.gql/connect-graphql
{::p.gql/namespace "univ3"}
#(request-subgraph % "https://api.thegraph.com/subgraphs/name/ianlapham/uniswap-v3-polygon"))
(p.gql/connect-graphql
{::p.gql/namespace "staker"}
#(request-subgraph % "https://api.thegraph.com/subgraphs/name/revert-finance/uni-v3-vesting-staker-polygon"))))
(p/let [env env]
(tap> env))
(p/let [result (p.eql/process
env
[{'(:staker.Query/incentives {:first 10})
[:staker.Incentive/id
:staker.Incentive/contract
:univ3.Token/symbol]}])]
(pprint/pprint result))
(comment
(p/let [env env]
(tap> env))
;; WORKS
(p/let [result (p.eql/process
env
[{'(:staker.Query/incentives {:first 10})
[:staker.Incentive/id
:staker.Incentive/contract
:univ3.Token/id]}])]
(pprint/pprint result))
;; **WANTED** but FAILS
(p/let [result (p.eql/process
env
[{'(:staker.Query/incentives {:first 10})
[:staker.Incentive/id
:staker.Incentive/contract
:univ3.Token/symbol]}])]
(pprint/pprint result))
;; FIXED
(p/let [result (p.eql/process
env
{:staker.Incentive/id "0x0bb698b687540a7f44504cf1063a4977d2351f201f18fc50281def0f36349d2e"}
[:staker.Incentive/contract
:univ3.Token/symbol])]
(pprint/pprint result))
;; FIXED
(p/let [result (p.eql/process
env
{:staker.Incentive/id "0x0bb698b687540a7f44504cf1063a4977d2351f201f18fc50281def0f36349d2e"}
[:staker.Incentive/contract])]
(pprint/pprint result)))
(defn init [] (js/console.log "hello"))