Liking cljdoc? Tell your friends :D

commando.commands.query-dsl


->>query-runclj/s

(->>query-run QueryExpression m)
source

->query-runclj/s

(->query-run m QueryExpression)
source

command-resolveclj/smultimethod

source

command-resolve-json-specclj/s

Description command-resolve-json-spec - like command-resolve-spec but use "string" keys instead of Keywords

Querying(internal execution) controlled by QueryExpression - custom DSL, what visually mention the EQL.

QueryExpression syntax example ["a0" ["b0" {"b0props" {}}] {"c0" ["a1" "b1" {"c1" ["a2" "b2"]}]} {["d0" {"d0props" {}}] ["a1" "b1"]}]

Example (defmethod commando.commands.builtin/command-mutation "generate-password" [_ _] {"random-string" (apply str (repeatedly 20 #(rand-nth "abcdefghijklmnopqrstuvwxyz0123456789")))})

(defmethod command-resolve "query-passport" [_ {:strs [first-name last-name QueryExpression]}] ;; Mocking SQL operation to db (when (and (= first-name "Adam") (= last-name "Nowak")) (->query-run {"number" "FA939393" "issued" "10-04-2020"} QueryExpression)))

(defmethod command-resolve "query-user" [_ {:strs [QueryExpression]}] (-> {"first-name" "Adam" "last-name" "Nowak" "info" {"age" 25 "weight" 70 "height" 188} "passport" (query-resolve "- no passport - " {"commando-resolve" "query-passport" "first-name" "Adam" "last-name" "Nowak"}) "password" (query-resolve "- no password - " {"commando-mutation" "generate-password"})} (->query-run QueryExpression)))

;; Let try to use it! (:instruction (commando.core/execute [commands-builtin/command-mutation-json-spec command-resolve-json-spec] {"commando-resolve" "query-user" "QueryExpression" ["first-name" {"info" ["age" "weight"]}]})) => {"first-name" "Adam", "info" {"age" 25, "weight" 70}}

;; do the same but with different QueryExpression

{"commando-resolve" "query-user" "QueryExpression" ["first-name" {"password" []}]} => {"first-name" "Adam", "password" {"random-string" "zz0fydanqzwd2cjyu7yc"}}

{"commando-resolve" "query-user" "QueryExpression" ["first-name" {"passport" ["number"]}]} => {"first-name" "Adam", "passport" {}}

{"commando-resolve" "query-user" "QueryExpression" ["first-name" "UNEXISTING"]} => {"first-name" "Adam", "UNEXISTING" {:status :failed, :errors [{:message "Commando. Graph Query. QueryExpression attribute 'UNEXISTING' is unreachable"}]}}

Parts commando.commands.query-dsl/query-resolve run internal call of commando/execute. commando.commands.query-dsl/->query-run trim query data according to passed QueryExpression commando.commands.query-dsl/command-resolve multimethod to declare resolvers.

See Also commando.core/execute commando.commands.query-dsl/command-mutation-spec commando.commands.builtin/command-mutation-spec

Description
  command-resolve-json-spec - like command-resolve-spec but
  use "string" keys instead of Keywords

  Querying(internal execution) controlled by QueryExpression - custom
  DSL, what visually mention the EQL.

QueryExpression syntax example
  ["a0"
   ["b0" {"b0props" {}}]
   {"c0"
    ["a1"
     "b1"
     {"c1"
      ["a2"
       "b2"]}]}
   {["d0" {"d0props" {}}]
    ["a1"
     "b1"]}]

 Example
   (defmethod commando.commands.builtin/command-mutation "generate-password" [_ _]
     {"random-string" (apply str (repeatedly 20 #(rand-nth "abcdefghijklmnopqrstuvwxyz0123456789")))})

   (defmethod command-resolve "query-passport" [_ {:strs [first-name last-name QueryExpression]}]
     ;; Mocking SQL operation to db
     (when (and
             (= first-name "Adam")
             (= last-name "Nowak"))
       (->query-run
         {"number" "FA939393"
          "issued" "10-04-2020"}
         QueryExpression)))

   (defmethod command-resolve "query-user" [_ {:strs [QueryExpression]}]
     (-> {"first-name" "Adam"
          "last-name" "Nowak"
          "info" {"age" 25 "weight" 70 "height" 188}
          "passport" (query-resolve
                      "- no passport - "
                      {"commando-resolve" "query-passport"
                       "first-name" "Adam"
                       "last-name" "Nowak"})
          "password" (query-resolve
                      "- no password - "
                      {"commando-mutation" "generate-password"})}
       (->query-run QueryExpression)))


   ;; Let try to use it!
   (:instruction
    (commando.core/execute
      [commands-builtin/command-mutation-json-spec
       command-resolve-json-spec]
      {"commando-resolve" "query-user"
       "QueryExpression"
       ["first-name"
        {"info"
         ["age"
          "weight"]}]}))
   => {"first-name" "Adam",
       "info" {"age" 25, "weight" 70}}

    ;; do the same but with different QueryExpression

   {"commando-resolve" "query-user"
    "QueryExpression"
    ["first-name"
     {"password" []}]}
    => {"first-name" "Adam",
        "password" {"random-string" "zz0fydanqzwd2cjyu7yc"}}

   {"commando-resolve" "query-user"
    "QueryExpression"
    ["first-name"
     {"passport"
      ["number"]}]}
    => {"first-name" "Adam", "passport" {}}

   {"commando-resolve" "query-user"
    "QueryExpression"
    ["first-name"
     "UNEXISTING"]}
    => {"first-name" "Adam",
        "UNEXISTING" {:status :failed,
                        :errors [{:message "Commando. Graph Query. QueryExpression attribute 'UNEXISTING' is unreachable"}]}}

 Parts
   `commando.commands.query-dsl/query-resolve` run internal call of `commando/execute`.
   `commando.commands.query-dsl/->query-run` trim query data according to passed QueryExpression
   `commando.commands.query-dsl/command-resolve` multimethod to declare resolvers.

 See Also
   `commando.core/execute`
   `commando.commands.query-dsl/command-mutation-spec`
   `commando.commands.builtin/command-mutation-spec`
sourceraw docstring

command-resolve-specclj/s

Description command-resolve-spec - behave like command-mutation-spec but allow invoking commando/execute internally inside the evaluation step, what make it usefull for querying data.

Querying(internal execution) controlled by QueryExpression - custom DSL, what visually mention the EQL.

QueryExpression Syntax Example [:a0 [:b0 {:b0props {}}] {:c0 [:a1 :b1 {:c1 [:a2 :b2]}]} {[:d0 {:d0props {}}] [:a1 :b1]}]

Example (defmethod commando.commands.builtin/command-mutation :generate-password [_ _] {:random-string (apply str (repeatedly 20 #(rand-nth "abcdefghijklmnopqrstuvwxyz0123456789")))})

(defmethod command-resolve :query-passport [_ {:keys [first-name last-name QueryExpression]}] ;; Mocking SQL operation to db (when (and (= first-name "Adam") (= last-name "Nowak")) (->query-run {:number "FA939393" :issued "10-04-2020"} QueryExpression)))

(defmethod command-resolve :query-user [_ {:keys [QueryExpression]}] (-> {:first-name "Adam" :last-name "Nowak" :info {:age 25 :weight 70 :height 188} :passport (query-resolve "- no passport - " {:commando/resolve :query-passport :first-name "Adam" :last-name "Nowak"}) :password (query-resolve "- no password - " {:commando/mutation :generate-password})} (->query-run QueryExpression)))

;; Let try to use it! (:instruction (commando.core/execute [commands-builtin/command-mutation-spec command-resolve-spec] {:commando/resolve :query-user :QueryExpression [:first-name {:info [:age :weight]}]})) => {:first-name "Adam" :info {:age 25, :weight 70}}

;; do the same but with different QueryExpression

[:first-name :password] => {:first-name "Adam", :password "- no password - "}

[:first-name {:password []}] => {:first-name "Adam", :password {:random-string "lexccpux2pzdupzwx79o"}}

[:first-name {:passport [:number]}] => {:first-name "Adam", :password {:number "FA939393"}}

[:first-name :UNEXISTING] => {:first-name "Adam", :UNEXISTING {:status :failed, :errors [{:message "Commando. Graph Query. QueryExpression attribute ':UNEXISTING' is unreachable"}]}}

Parts commando.commands.query-dsl/query-resolve run internal call of commando/execute. commando.commands.query-dsl/->query-run trim query data according to passed QueryExpression commando.commands.query-dsl/command-resolve multimethod to declare resolvers.

See Also commando.core/execute commando.commands.query-dsl/command-mutation-spec commando.commands.builtin/command-mutation-spec

Description
  command-resolve-spec - behave like command-mutation-spec
  but allow invoking `commando/execute` internally inside the
  evaluation step, what make it usefull for querying data.

  Querying(internal execution) controlled by QueryExpression - custom
  DSL, what visually mention the EQL.

QueryExpression Syntax Example
 [:a0
  [:b0 {:b0props {}}]
  {:c0
   [:a1
    :b1
    {:c1
     [:a2
      :b2]}]}
  {[:d0 {:d0props {}}]
   [:a1
    :b1]}]

 Example
   (defmethod commando.commands.builtin/command-mutation :generate-password [_ _]
     {:random-string (apply str (repeatedly 20 #(rand-nth "abcdefghijklmnopqrstuvwxyz0123456789")))})

   (defmethod command-resolve :query-passport [_ {:keys [first-name last-name QueryExpression]}]
     ;; Mocking SQL operation to db
     (when (and
             (= first-name "Adam")
             (= last-name "Nowak"))
       (->query-run
         {:number "FA939393"
          :issued "10-04-2020"}
         QueryExpression)))

   (defmethod command-resolve :query-user [_ {:keys [QueryExpression]}]
     (-> {:first-name "Adam"
          :last-name "Nowak"
          :info {:age 25 :weight 70 :height 188}
          :passport (query-resolve
                      "- no passport - "
                      {:commando/resolve :query-passport
                       :first-name "Adam"
                       :last-name "Nowak"})
          :password (query-resolve
                      "- no password - "
                      {:commando/mutation :generate-password})}
       (->query-run QueryExpression)))


   ;; Let try to use it!
   (:instruction
     (commando.core/execute
       [commands-builtin/command-mutation-spec
        command-resolve-spec]
       {:commando/resolve :query-user
        :QueryExpression
        [:first-name
         {:info
          [:age
           :weight]}]}))
    => {:first-name "Adam"
        :info {:age 25, :weight 70}}

    ;; do the same but with different QueryExpression

   [:first-name
    :password]
    => {:first-name "Adam", :password "- no password - "}

   [:first-name
    {:password []}]
    => {:first-name "Adam", :password {:random-string "lexccpux2pzdupzwx79o"}}

   [:first-name
    {:passport
     [:number]}]
    => {:first-name "Adam", :password {:number "FA939393"}}

   [:first-name
    :UNEXISTING]
    => {:first-name "Adam",
        :UNEXISTING {:status :failed, :errors [{:message "Commando. Graph Query. QueryExpression attribute ':UNEXISTING' is unreachable"}]}}

 Parts
   `commando.commands.query-dsl/query-resolve` run internal call of `commando/execute`.
   `commando.commands.query-dsl/->query-run` trim query data according to passed QueryExpression
   `commando.commands.query-dsl/command-resolve` multimethod to declare resolvers.

 See Also
   `commando.core/execute`
   `commando.commands.query-dsl/command-mutation-spec`
   `commando.commands.builtin/command-mutation-spec`
sourceraw docstring

query-resolveclj/s

(query-resolve default-value Instruction)

Take default-value, Instruction, and if QueryExpression ask for property, then execute Instruction(internal ivoke of commanod/execute) and return the result, otherwise return default-value

[:value-covered-by-query-resolve] <- return default-value [{:value-covered-by-query-resolve <- execute Instruction and lookup for :SOME-VALUES [:SOME-VALUES]}]

Take `default-value`, `Instruction`, and if QueryExpression ask for property, then
execute `Instruction`(internal ivoke of commanod/execute) and return the result,
otherwise return `default-value`

[:value-covered-by-query-resolve] <- return `default-value`
[{:value-covered-by-query-resolve <- execute `Instruction` and lookup for `:SOME-VALUES`
  [:SOME-VALUES]}]
sourceraw docstring

query-resolve?clj/s

(query-resolve? obj)
source

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close