(ast-key-id ast)
DEPRECATED: use ident-value instead
DEPRECATED: use ident-value instead
(elide-ast-nodes {:keys [key union-key] :as ast} elision-set)
Remove items from a query (AST) that have a key listed in the elision-set
Remove items from a query (AST) that have a key listed in the elision-set
(elide-items item-set input)
Removes any item on set item-set from the input
Removes any item on set item-set from the input
(elide-not-found input)
Convert all ::p/not-found values of maps to nil
Convert all ::p/not-found values of maps to nil
(entity env)
(entity {:keys [parser] :as env} attributes)
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 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.
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 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.
(entity-attr env attr)
(entity-attr env attr default)
Helper function to fetch a single attribute from current entity.
Helper function to fetch a single attribute from current entity.
(entity-attr! env attr)
Like entity-attr. Raises an exception if the property can't be retrieved.
Like entity-attr. Raises an exception if the property can't be retrieved.
(entity-dispatch {:keys [ast]})
Dispatch on the first element (type) of an incoming ident.
Dispatch on the first element (type) of an incoming ident.
(entity-value-merge x y)
This is used for merging new parsed attributes from entity, works like regular merge but if the value from the right direction is not found, then the previous value will be kept.
This is used for merging new parsed attributes from entity, works like regular merge but if the value from the right direction is not found, then the previous value will be kept.
(env-placeholder-reader {:com.wsscode.pathom.core/keys [placeholder-prefixes]
:as env})
Produces a reader that will respond to any keyword whose namespace
is in the set (::placeholder-prefixes env)
. The join node logical
level stays the same as the parent where the placeholder node is
requested.
Produces a reader that will respond to any keyword whose namespace is in the set `(::placeholder-prefixes env)`. The join node logical level stays the same as the parent where the placeholder node is requested.
(env-wrap-plugin extra-env-wrapper)
This plugin receives a function that will be called to wrap the current enviroment each time the main parser is called (parser level).
This plugin receives a function that will be called to wrap the current enviroment each time the main parser is called (parser level).
(ident-join-reader env)
This reader will join on any ident join, the entity for the join will be a map containing the same key and value expressed on the ident, eg: [{[:id 123] [:id]}], the join entry will be {:id 123}.
This reader will join on any ident join, the entity for the join will be a map containing the same key and value expressed on the ident, eg: [{[:id 123] [:id]}], the join entry will be {:id 123}.
(ident-key {:keys [ast]})
The first element of an ident.
The first element of an ident.
(ident-value {:keys [ast]})
The second element of an ident
The second element of an ident
(join {:keys [parser ast query]
:com.wsscode.pathom.core/keys [union-path parent-query
processing-sequence placeholder-prefixes]
:as env})
(join entity {:com.wsscode.pathom.core/keys [entity-key] :as env})
Runs a parser with current sub-query. When run with an entity
argument, that entity is set as the new environment
value of ::entity
, and the subquery is parsered with that new environment. When run without an entity
it
parses the current subquery in the context of whatever entity was already in ::entity
of the env.
Runs a parser with current sub-query. When run with an `entity` argument, that entity is set as the new environment value of `::entity`, and the subquery is parsered with that new environment. When run without an `entity` it parses the current subquery in the context of whatever entity was already in `::entity` of the env.
(join-seq {:com.wsscode.pathom.core/keys [entity-key] :as env} coll)
Runs the current subquery against the items of the given collection.
Runs the current subquery against the items of the given collection.
(js-obj-reader {:keys [query ast]
:com.wsscode.pathom.core/keys [js-key-transform
js-value-transform entity-key]
:as env
:or {js-key-transform name js-value-transform (fn [_ v] v)}})
Like map-reader*, but handles plain Javascript objects instead of Clojure maps.
Like map-reader*, but handles plain Javascript objects instead of Clojure maps.
(lift-placeholders {:com.wsscode.pathom.core/keys [placeholder-prefixes]} query)
This will lift the queries from placeholders to the same level of the query, as if there was not placeholders in it.
This will lift the queries from placeholders to the same level of the query, as if there was not placeholders in it.
(map-reader {:keys [ast query] :as env})
Map reader will try to find the ast key on the current entity and output it. When the value is a map and a sub query is present, it will apply the sub query on that value (recursively). When the value is a sequence, map-reader will do a join on each of the items (and apply sub queries if it's present and values are maps.
Map-reader will defer the read when the key is not present at entity.
Map reader will try to find the ast key on the current entity and output it. When the value is a map and a sub query is present, it will apply the sub query on that value (recursively). When the value is a sequence, map-reader will do a join on each of the items (and apply sub queries if it's present and values are maps. Map-reader will defer the read when the key is not present at entity.
(map-reader* {:com.wsscode.pathom.core/keys [map-key-transform
map-value-transform]})
Like map-reader, but it has extra options (read from the environment): map-key-transform: (fn [key]) will transform the key on the AST before trying to match with entity key map-value-transform: (fn [key value]) will transform the output value after reading from the entity.
The reason to have a separated reader is so the plain version (map-reader) can be faster by avoiding checking the presence of transform functions.
Like map-reader, but it has extra options (read from the environment): map-key-transform: (fn [key]) will transform the key on the AST before trying to match with entity key map-value-transform: (fn [key value]) will transform the output value after reading from the entity. The reason to have a separated reader is so the plain version (map-reader) can be faster by avoiding checking the presence of transform functions.
(pathom-read {:com.wsscode.pathom.core/keys [reader process-reader] :as env}
_
_)
DEPRECATED: use p/parser to create your parser
DEPRECATED: use p/parser to create your parser
(placeholder-reader)
(placeholder-reader ns)
DEPRECATED: use env-placeholder-reader instead.
Produces a reader that will respond to any keyword with the namespace ns. The join node logical level stays the same as the parent where the placeholder node is requested.
DEPRECATED: use env-placeholder-reader instead. Produces a reader that will respond to any keyword with the namespace ns. The join node logical level stays the same as the parent where the placeholder node is requested.
(post-process-parser-plugin f)
Helper to create a plugin to work on the parser output. f
will run once with the parser final result.
Helper to create a plugin to work on the parser output. `f` will run once with the parser final result.
(query->ast query-expr)
Given a query expression convert it into an AST.
Given a query expression convert it into an AST.
(query->ast1 query-expr)
Call query->ast and return the first children.
Call query->ast and return the first children.
(raise-response resp)
Mutations running through a parser all come back in a map like this {'my/mutation {:result {...}}}. This function converts that to {'my/mutation {...}}. Copied from fulcro.server.
Mutations running through a parser all come back in a map like this {'my/mutation {:result {...}}}. This function converts that to {'my/mutation {...}}. Copied from fulcro.server.
(read-from env reader)
Runs the read process for the reading, the reader can be a function, a vector or a map:
function: will receive the environment as argument map: will dispatch from the ast key to a reader on the map value vector: will try to run each reader in sequence, when a reader returns ::p/continue it will try the next
Runs the read process for the reading, the reader can be a function, a vector or a map: function: will receive the environment as argument map: will dispatch from the ast key to a reader on the map value vector: will try to run each reader in sequence, when a reader returns ::p/continue it will try the next
(swap-entity! env fn & args)
Helper to swap the current entity value.
Helper to swap the current entity value.
(transduce-children xform {:keys [children] :as node})
Recursivelly transduce children on the AST, you can use this to apply filter/transformations on a whole AST. Each iteration of the transducer will get a single AST node to process.
(->> [:a {:b [:c :d]} :e]
(p/query->ast)
(p/transduce-children (remove (comp #{:a :c} :key)))
(p/ast->query))
; => [{:b [:d]} :e]
Recursivelly transduce children on the AST, you can use this to apply filter/transformations on a whole AST. Each iteration of the transducer will get a single AST node to process. ``` (->> [:a {:b [:c :d]} :e] (p/query->ast) (p/transduce-children (remove (comp #{:a :c} :key))) (p/ast->query)) ; => [{:b [:d]} :e] ```
(transduce-maps xform input)
Walk the structure and transduce every map with xform.
Walk the structure and transduce every map with xform.
(union-children? ast)
Given an AST point, check if the children is a union query type.
Given an AST point, check if the children is a union query type.
(update-action m f)
Helper function to update a mutation action.
Helper function to update a mutation action.
(update-attribute-param x f & args)
Add attribute param, eg:
(p/update-attribute-param :keyword assoc :foo "bar") => (:keyword {:foo "bar"})
(p/update-attribute-param '(:keyword {:param "prev"}) assoc :foo "bar") => (:keyword {:foo "bar" :param "prev"})
Add attribute param, eg: ``` (p/update-attribute-param :keyword assoc :foo "bar") => (:keyword {:foo "bar"}) (p/update-attribute-param '(:keyword {:param "prev"}) assoc :foo "bar") => (:keyword {:foo "bar" :param "prev"}) ```
(update-child ast key & args)
Given an AST, find the child with a given key and run update against it.
Given an AST, find the child with a given key and run update against it.
(update-recursive-depth ast key & args)
Given an AST, find the child with a given key and run update against it.
Given an AST, find the child with a given key and run update against it.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close