graphql updates.

This commit is contained in:
Bryce Covert
2018-04-12 13:13:11 -07:00
parent 7425f7f393
commit 812292b5aa
4 changed files with 39 additions and 21 deletions

View File

@@ -34,15 +34,19 @@
:company_id {:type 'Int}
:vendor {:type :vendor
:resolve :get-vendor}
:resolve :get-vendor-for-invoice}
:company {:type :company
:resolve :get-company}}}}
:resolve :get-company-for-invoice}}}}
:queries
{:invoice {:type '(list :invoice)
:args {:imported {:type 'Boolean}
:company_id {:type 'Int}}
:resolve :get-invoice}}})
:resolve :get-invoice}
:company {:type '(list :company)
:resolve :get-company}
:vendor {:type '(list :vendor)
:resolve :get-vendor}}})
(defn by [x kf]
(reduce
@@ -99,23 +103,33 @@
->graphql
(invoices/get-graphql (<-graphql args))) extra-context)))
(defn get-vendor [context args value]
(defn get-vendor-for-invoice [context args value]
(->graphql
(if-let [vendor-cache (:vendor-cache context)]
(vendor-cache (:vendor_id value))
(vendors/get-by-id (:vendor_id value)))))
(defn get-company [context args value]
(defn get-company-for-invoice [context args value]
(->graphql
(if-let [company-cache (:company-cache context)]
(company-cache (:company_id value))
(companies/get-by-id (:company_id value)))))
(defn get-company [context args value]
(->graphql
(companies/get-all)))
(defn get-vendor [context args value]
(->graphql
(vendors/get-all)))
(def schema
(-> integreat-schema
(attach-resolvers {:get-invoice get-invoice
:get-vendor get-vendor
:get-company get-company})
:get-vendor-for-invoice get-vendor-for-invoice
:get-company-for-invoice get-company-for-invoice
:get-company get-company
:get-vendor get-vendor})
schema/compile))