Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use superfetcher in resolver #64

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions src/gosura/helpers/resolver2.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"gosura.helpers.resolver의 v2입니다."
(:require [com.walmartlabs.lacinia.resolve :refer [resolve-as]]
[failjure.core :as f]
[camel-snake-kebab.core :as csk]
[gosura.auth :as auth]
[gosura.helpers.error :as error]
[gosura.helpers.relay :as relay]
Expand Down Expand Up @@ -88,7 +89,8 @@
* arguments 쿼리 입력
* parent 부모 노드
* config 리졸버 동작 설정
* :superfetcher: 슈퍼페처
* :db-key 사용할 DB 이름
* :fetch fetch 함수
* :post-process-row: 결과 객체 목록 후처리 함수 (예: identity)
* :parent-id: 부모로부터 전달되는 id 정보 예) {:pre-fn relay/decode-global-id->db-id :prop :id :agg :id} {:prop :user-id :agg :id}
* :pre-fn: 전처리
Expand All @@ -99,7 +101,7 @@
"
[context arguments parent {:keys [db-key
node-type
superfetcher
fetch
parent-id
post-process-row
additional-filter-opts]}]
Expand All @@ -120,7 +122,10 @@
{:id load-id
:page-options page-options
:agg agg})
superfetch-id (hash superfetch-arguments)]
superfetch-id (hash superfetch-arguments)
superfetcher-name (gensym (str "FetchBy" (csk/->PascalCase (name prop))))
superfetcher `(superfetcher-v2 ~superfetcher-name {:db-key ~db-key
:table-fetcher ~fetch})]
(with-superlifter (:superlifter context)
(-> (superlifter-api/enqueue! db-key (superfetcher superfetch-id superfetch-arguments))
(prom/then (fn [rows]
Expand All @@ -136,8 +141,8 @@
* arguments 쿼리 입력
* parent 부모 노드
* config 리졸버 동작 설정
* :db-key 사용할 DB 이름
* :superfetcher 슈퍼페처
* :db-key 사용할 DB 이름
* :fetch fetch 함수
* :post-process-row 결과 객체 목록 후처리 함수 (예: identity)
* :parent-id: 부모로부터 전달되는 id 정보 예) {:pre-fn relay/decode-global-id->db-id :prop :id :agg :id} {:prop :user-id :agg :id}
* :pre-fn: 전처리
Expand All @@ -148,7 +153,7 @@
"
[context _arguments parent {:keys [db-key
node-type
superfetcher
fetch
post-process-row
parent-id
additional-filter-opts]}]
Expand All @@ -161,7 +166,10 @@
{:id load-id
:page-options nil
:agg agg})
superfetch-id (hash superfetch-arguments)]
superfetch-id (hash superfetch-arguments)
superfetcher-name (gensym (str "FetchBy" (csk/->PascalCase (name prop))))
superfetcher `(superfetcher-v2 ~superfetcher-name {:db-key ~db-key
:table-fetcher ~fetch})]
(with-superlifter (:superlifter context)
(-> (superlifter-api/enqueue! db-key (superfetcher superfetch-id superfetch-arguments))
(prom/then (fn [rows] (-> (first rows)
Expand Down