Generic query expression parsing and AST manipulation.
QUERY EXPRESSIONS
Query expressions are a variation on Datomic Pull Syntax http://docs.datomic.com/pull.html more suitable for generic client/server state transfer. It's important to note the query expression syntax is not a strict superset of Datomic Pull.
A query expression is composed of EDN values. The grammar for query expressions follows:
QueryRoot := EdnVector(QueryExpr*) PlainQueryExpr := (EdnKeyword | IdentExpr | JoinExpr) QueryExpr := (PlainQueryExpr | ParamExpr) IdentExpr := EdnVector2(Keyword, EdnValue) ParamExpr := EdnList2(PlainQueryExpr | EdnSymbol, ParamMapExpr) ParamMapExpr := EdnMap(Keyword, EdnValue) JoinExpr := EdnMap((Keyword | IdentExpr), (QueryRoot | UnionExpr | RecurExpr)) UnionExpr := EdnMap(Keyword, QueryRoot) RecurExpr := ('... | Integer)
Note most of the api expects a QueryRoot not a QueryExpr.
QUERY EXPRESSION AST FORMAT
Given a QueryExpr you can get the AST via om.next.impl.parser/expr->ast. The following keys can appear in the AST representation:
{:type (:prop | :join | :call | :root | :union | :union-entry) :key (EdnKeyword | EdnSymbol | IdentExpr) :dispatch-key (EdnKeyword | EdnSymbol) :union-key EdnKeyword :query (QueryRoot | RecurExpr) :params ParamMapExpr :children EdnVector(AST) :component Object :target EdnKeyword}
:query and :params may or may not appear. :type :call is only for mutations.
Generic query expression parsing and AST manipulation. QUERY EXPRESSIONS Query expressions are a variation on Datomic Pull Syntax http://docs.datomic.com/pull.html more suitable for generic client/server state transfer. It's important to note the query expression syntax is *not* a strict superset of Datomic Pull. A query expression is composed of EDN values. The grammar for query expressions follows: QueryRoot := EdnVector(QueryExpr*) PlainQueryExpr := (EdnKeyword | IdentExpr | JoinExpr) QueryExpr := (PlainQueryExpr | ParamExpr) IdentExpr := EdnVector2(Keyword, EdnValue) ParamExpr := EdnList2(PlainQueryExpr | EdnSymbol, ParamMapExpr) ParamMapExpr := EdnMap(Keyword, EdnValue) JoinExpr := EdnMap((Keyword | IdentExpr), (QueryRoot | UnionExpr | RecurExpr)) UnionExpr := EdnMap(Keyword, QueryRoot) RecurExpr := ('... | Integer) Note most of the api expects a QueryRoot not a QueryExpr. QUERY EXPRESSION AST FORMAT Given a QueryExpr you can get the AST via om.next.impl.parser/expr->ast. The following keys can appear in the AST representation: {:type (:prop | :join | :call | :root | :union | :union-entry) :key (EdnKeyword | EdnSymbol | IdentExpr) :dispatch-key (EdnKeyword | EdnSymbol) :union-key EdnKeyword :query (QueryRoot | RecurExpr) :params ParamMapExpr :children EdnVector(AST) :component Object :target EdnKeyword} :query and :params may or may not appear. :type :call is only for mutations.
(ast->expr ast)
(ast->expr {:keys [type component] ast-meta :meta :as ast} unparse?)
Given a query expression AST convert it back into a query expression.
Given a query expression AST convert it back into a query expression.
(expr->ast x)
Given a query expression convert it into an AST.
Given a query expression convert it into an AST.
(parser {:keys [read mutate] :as config})
Given a :read and/or :mutate function return a parser. Refer to fulcro.client.primitives/parser for top level documentation.
Given a :read and/or :mutate function return a parser. Refer to fulcro.client.primitives/parser for top level documentation.
(path-meta data path query)
(path-meta data path query union-expr)
Add path metadata to a data structure. data is the data to be worked on. path is the current path into the data. query is the query used to walk the data. union-expr tracks the last seen union query to be used when it finds a recursive union.
Add path metadata to a data structure. data is the data to be worked on. path is the current path into the data. query is the query used to walk the data. union-expr tracks the last seen union query to be used when it finds a recursive union.
(query->ast query)
Convert a query to its AST representation.
Convert a query to its AST representation.
(substitute-root-path-for-ident data-tree replacement-root-path query)
Given the result (and query) of an ident-based query like:
[{[:TABLE :ID] (get-query C)}]
a query response data tree:
{ [:TABLE :ID] { ...props for C...} }
and a replacement-root-path such as [:ROOT/subcomponent :subcomponent/items 0], adds path metadata to the val (props for C) of that data tree as-if it had been queried from the UI root (replacement-root-path). E.g. the path metadata on the val (props of C) will START at replacement-root-path.
Given the result (and query) of an ident-based query like: [{[:TABLE :ID] (get-query C)}] a query response data tree: { [:TABLE :ID] { ...props for C...} } and a replacement-root-path such as [:ROOT/subcomponent :subcomponent/items 0], adds path metadata to the val (props for C) of that data tree as-if it had been queried from the UI root (replacement-root-path). E.g. the path metadata on the val (props of C) will START at replacement-root-path.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close