all columns available.
This commit is contained in:
@@ -73,6 +73,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
:check {:fields {:id {:type 'Int}
|
||||
:amount {:type 'String}
|
||||
:vendor {:type :vendor
|
||||
@@ -80,9 +82,15 @@
|
||||
:company {:type :company
|
||||
:resolve :get-company-for-check}
|
||||
:date {:type 'String}
|
||||
:bank_account {:type :bank_account
|
||||
:resolve :bank-account-for-check}
|
||||
:memo {:type 'String}
|
||||
:s3_url {:type 'String}
|
||||
:check_number {:type 'Int}
|
||||
:status {:type 'String}}}
|
||||
:status {:type 'String}
|
||||
:invoices {:type '(list :invoice_check)
|
||||
:resolve :get-checks-invoices}
|
||||
}}
|
||||
|
||||
:transaction {:fields {:id {:type 'Int}
|
||||
:amount {:type 'String}
|
||||
@@ -98,6 +106,7 @@
|
||||
:invoice_check
|
||||
{:fields {:id {:type 'Int}
|
||||
:amount {:type 'String}
|
||||
:invoice_id {:type 'Int}
|
||||
:check_id {:type 'Int}
|
||||
:check {:type :check
|
||||
:resolve :get-check-by-id}}}
|
||||
@@ -183,6 +192,14 @@
|
||||
|
||||
:resolve :get-invoice-page}
|
||||
|
||||
:all_invoices {:type '(list :invoice)
|
||||
:args {:company_id {:type 'Int}}
|
||||
:resolve :get-all-invoices}
|
||||
|
||||
:all_checks {:type '(list :check)
|
||||
:args {:company_id {:type 'Int}}
|
||||
:resolve :get-all-checks}
|
||||
|
||||
:transaction_page {:type '(list :transaction_page)
|
||||
:args {:company_id {:type 'Int}
|
||||
:start {:type 'Int}
|
||||
@@ -318,6 +335,35 @@
|
||||
:start (:start args 0)
|
||||
:end (+ (:start args 0) (count invoices))}] extra-context)))
|
||||
|
||||
(defn get-all-invoices [context args value]
|
||||
(let [extra-context
|
||||
(cond-> {}
|
||||
(executor/selects-field? context :invoice/vendor) (assoc :vendor-cache (by :id (vendors/get-all)))
|
||||
(executor/selects-field? context :invoice/company) (assoc :company-cache (by :id (companies/get-all))))
|
||||
|
||||
|
||||
invoices (map
|
||||
->graphql
|
||||
(invoices/get-graphql (assoc (<-graphql args)
|
||||
:limit Integer/MAX_VALUE)))]
|
||||
(resolve/with-context
|
||||
invoices extra-context)))
|
||||
|
||||
(defn get-all-checks [context args value]
|
||||
(let [extra-context
|
||||
(cond-> {}
|
||||
(executor/selects-field? context :invoice/vendor) (assoc :vendor-cache (by :id (vendors/get-all)))
|
||||
(or (executor/selects-field? context :check/company)
|
||||
(executor/selects-field? context :check/bank_account)) (assoc :company-cache (by :id (companies/get-all))))
|
||||
|
||||
|
||||
checks (map
|
||||
->graphql
|
||||
(checks/get-graphql (assoc (<-graphql args)
|
||||
:limit Integer/MAX_VALUE)))]
|
||||
(resolve/with-context
|
||||
checks extra-context)))
|
||||
|
||||
(defn get-reminder-page [context args value]
|
||||
(let [extra-context
|
||||
(cond-> {}
|
||||
@@ -348,12 +394,23 @@
|
||||
(->graphql
|
||||
(invoices-checks/get-for-invoice-id (:id value))))
|
||||
|
||||
(defn get-checks-invoices [context args value]
|
||||
(->graphql
|
||||
(invoices-checks/get-for-check-id (:id 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 bank-account-for-check [context args value]
|
||||
(->graphql
|
||||
(let [company (if-let [company-cache (:company-cache context)]
|
||||
(company-cache (:company_id value))
|
||||
(companies/get-by-id (:company_id value)))]
|
||||
(first (filter #(= (:id %) (:bank_account_id value)) (:bank-accounts company))) )))
|
||||
|
||||
(defn get-user-companies [context args value]
|
||||
(->graphql
|
||||
(if-let [company-cache (:company-cache context)]
|
||||
@@ -401,6 +458,10 @@
|
||||
(def schema
|
||||
(-> integreat-schema
|
||||
(attach-resolvers {:get-invoice-page get-invoice-page
|
||||
:get-all-invoices get-all-invoices
|
||||
:get-all-checks get-all-checks
|
||||
:bank-account-for-check bank-account-for-check
|
||||
|
||||
:get-check-page gq-checks/get-check-page
|
||||
:get-transaction-page gq-transactions/get-transaction-page
|
||||
:get-reminder-page get-reminder-page
|
||||
@@ -411,6 +472,7 @@
|
||||
:get-check-for-transaction gq-transactions/get-check-for-transaction
|
||||
:get-company-for-invoice get-company-for-invoice
|
||||
:get-invoices-checks get-invoices-checks
|
||||
:get-checks-invoices get-checks-invoices
|
||||
:get-check-by-id get-check-by-id
|
||||
:get-invoices-expense-accounts gq-invoices/get-invoices-expense-accounts
|
||||
:get-company get-company
|
||||
@@ -452,5 +514,5 @@
|
||||
([id q]
|
||||
(query id q nil ))
|
||||
([id q v]
|
||||
(println id q v)
|
||||
(println "executing graphql query" id q v)
|
||||
(simplify (execute schema q v {:identity id}))))
|
||||
|
||||
Reference in New Issue
Block a user