Fork me on GitHub
#untangled
<
2016-08-30
>
kenbier00:08:34

@darrellesh: sweet! I'll send you a private message soon.

gardnervickers03:08:04

Hey! Should this be something other than contains? https://github.com/untangled-web/untangled-client/blob/b1eb776d3bfff2035dcbcf521f9060a6cf30cd61/src/untangled/client/impl/data_fetch.cljs#L127 I have a query that after running query->ast returns something like {:key [:item-list [{…}]]}, and elide-ast-nodes can’t remove the :item-list keyword because contains? on a vector checks if the numeric key is within the vectors range.

gardnervickers03:08:09

This is part of a union query, so I might be doing something wrong here...

ethangracer03:08:33

@gardnervickers: I'm not sure that any of the apps that we've made so far send a union query to the server, so it's quite possible that there's a bug in there. I believe all that function does is remove the keywords from the :without set on a data fetch

gardnervickers03:08:54

Gotcha, I was trying to load data for all tabs except one, but I can also just load each individually.

darrellesh03:08:59

@ethangracer Have you landed in NYC?

ethangracer03:08:48

@gardnervickers: how you interpret the query on the server is up to you, Untangled should respect elisions from your Union query. If you can submit a small repro as an issue I can take a look at it

darrellesh03:08:14

@ethangracer Talk to you in the morning...

ethangracer03:08:21

@gardnervickers: we'll have to be careful though because eliding a keyword in the Union itself could generate the wrong ast if eliding that keyword turns the union into a join

gardnervickers03:08:51

Ok no problem,

(elide-ast-nodes
 (om/query->ast
  [{:current-tab {:console [:data]
                  :dashboard [:data]}}])
 #{:console})
That will not elide anything in the query. In elide-ast-nodes, checking for (contains? elision-set union-key) in addition to key yields the desired results but I’m not sure what happens if, like you said, a union only has one thing in it.

ethangracer03:08:38

@gardnervickers: thanks! I'll investigate in the morning

gardnervickers03:08:47

(defn elide-ast-nodes
  "Remove items from a query (AST) that have a key listed in the elision-set"
  [{:keys [key union-key] :as ast} elision-set]
  (when-not (or (contains? elision-set key)
                (contains? elision-set union-key))
    (update ast :children (fn [c] (vec (keep #(elide-ast-nodes % elision-set) c))))))

ethangracer14:08:31

@gardnervickers: that looks good to me. I think if the dev removes a keyword from the union query that violates how a union query should be constructed, it’s not on us. I might log a warning

ethangracer14:08:55

thanks for letting us know

ethangracer15:08:04

I’m gonna let it sit for a bit to make sure we’re not missing something but I think that’s it

tony.kay17:08:37

pull request merged

tony.kay17:08:07

0.5.5-SNAPSHOT updated on clojars @ethangracer @gardnervickers

tony.kay17:08:28

sure, thanks for the report