 (defn entity
   "Fetch the entity according to the ::entity-key. If the entity is an IAtom, it will be derefed.
 
-  If a second argument is sent, calls the parser against current element to garantee that some fields are loaded. This
-  is useful when you need to ensure some values are loaded in order to fetch some more complex data."
+  If a second argument is sent, calls the parser against current element to guarantee that some fields are loaded. This
+  is useful when you need to ensure some values are loaded in order to fetch some more complex data. NOTE: When using
+  this call with an explicit vector of attributes the parser will not be invoked for attributes that already exist in
+  the current value of the current entity."
   ([env]
    (let [e (raw-entity env)]
      (if (atom? e) (deref e) e)))

  (into [] (remove #{'*}) query))

(defn join
  "Runs a parser with current sub-query."
  ([entity {::keys [entity-key] :as env}] (join (assoc env entity-key entity)))
  ([{:keys  [parser ast query]
     ::keys [union-path parent-query]

       (keyword? (first x))
       (= 2 (count x))))

(defn ident-key
  "The first element of an ident."
  [{:keys [ast]}]
  (let [key (some-> ast :key)]
    (if (vector? key) (first key))))

(defn ident-value
  "The second element of an ident"
  [{:keys [ast]}]
  (let [key (some-> ast :key)]
    (if (sequential? key) (second key))))

