Skip to content

Commit

Permalink
Merge pull request #20 from district0x/release-1.0.16
Browse files Browse the repository at this point in the history
Implement ::query! Release 1.0.16
  • Loading branch information
madis committed Mar 12, 2024
2 parents 2485b52 + 250cbad commit 5fc7137
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject district0x/district-ui-graphql "1.0.15-SNAPSHOT"
(defproject district0x/district-ui-graphql "1.0.16-SNAPSHOT"
:description "district UI module for GraphQL integration"
:url "https://github.com/district0x/district-ui-graphql"
:license {:name "Eclipse Public License"
Expand Down
2 changes: 1 addition & 1 deletion src/district/ui/graphql/effects.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
(utils/merge-in-colls acc res)))
{}
resps)
(utils/remove-empty-typename-paths))]
(utils/remove-empty-typename-paths))]
(when on-response
(dispatch (vec (concat on-response [res req-opts]))))
(if (empty? (:errors res))
Expand Down
20 changes: 20 additions & 0 deletions src/district/ui/graphql/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,26 @@
:dispatch-to [::query (dissoc opts :refetch-on :refetch-id)]}})))))


(reg-event-fx
::query!
interceptors
(fn [{:keys [:db]} [{:keys [:queries :query :variables :on-success :on-error] :as opts}]]
(let [query (cond->> query
(some? queries) (merge-with into {:queries queries})
true (merge {:operation {:operation/type :query
:operation/name :a-query}}))
{:keys [:url :kw->gql-name :gql-name->kw :query-middlewares :fetcher :schema]} (queries/config db)
{:keys [:query :query-str]} (utils/parse-query query {:kw->gql-name kw->gql-name})]

{::effects/fetch {:fetcher (queries/config db :fetcher)
:query query
:variables variables
:on-success [::mutation-success {:on-success on-success}]
:on-error [::mutation-error {:on-error on-error}]
:gql-name->kw gql-name->kw
:query-middlewares query-middlewares
:schema schema}})))

(reg-event-fx
::mutation
interceptors
Expand Down

0 comments on commit 5fc7137

Please sign in to comment.