(ast->query query-ast)
Given an AST convert it back into a query expression.
Given an AST convert it back into a query expression.
(ast->shape-descriptor ast)
Convert AST to shape descriptor format
Convert AST to shape descriptor format
(ast-key-id ast)
DEPRECATED: use ident-value instead
DEPRECATED: use ident-value instead
(ast-properties {:keys [children]})
Takes an AST and return a single set with all properties that appear in a query.
Example:
(-> [:foo {:bar [:baz]}] eql/query->ast pc/all-out-attributes) ; => #{:foo :bar :baz}
Takes an AST and return a single set with all properties that appear in a query. Example: (-> [:foo {:bar [:baz]}] eql/query->ast pc/all-out-attributes) ; => #{:foo :bar :baz}
(async-parser settings)
Create a new pathom async parser, this parser is serial and capable of waiting for core.async to continue processing, allowing async operations to happen during the parsing.
Options to tune the parser:
::p/env - Use this key to provide a default environment for the parser. This is a sugar to use the p/env-plugin.
::p/mutate - A mutate function that will be called to run mutations, this function must have the signature: (mutate env key params)
::p/plugins - A vector with plugins.
Create a new pathom async parser, this parser is serial and capable of waiting for core.async to continue processing, allowing async operations to happen during the parsing. Options to tune the parser: ::p/env - Use this key to provide a default environment for the parser. This is a sugar to use the p/env-plugin. ::p/mutate - A mutate function that will be called to run mutations, this function must have the signature: (mutate env key params) ::p/plugins - A vector with plugins.
(cached-async
{:com.wsscode.pathom.core/keys [async-request-cache-ch request-cache] :as env}
key
f)
(collapse-error-path m path)
Reduces the error path to the last available nesting on the map m.
Reduces the error path to the last available nesting on the map m.
(deep-merge & xs)
Merges nested maps without overwriting existing keys.
Merges nested maps without overwriting existing keys.
(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
(elide-special-outputs input)
Convert all ::p/not-found values of maps to nil
Convert all ::p/not-found values of maps to nil
(ensure-attrs env attributes)
DEPRECATED: use p/entity Runs 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.
DEPRECATED: use p/entity Runs 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.
(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).
Wrap reads with try-catch and put any errors under ::p/errors
(including the path),
setting the value of the errored node to ::p/reader-error
.
You can customize how the error is exported into the ::p/errors
map by setting the key
::p/process-error
in your environment to a function of [env, err] -> data.
Wrap reads with try-catch and put any errors under `::p/errors` (including the path), setting the value of the errored node to `::p/reader-error`. You can customize how the error is exported into the `::p/errors` map by setting the key `::p/process-error` in your environment to a function of [env, err] -> data.
(find-closest-non-placeholder-parent-join-key
{:com.wsscode.pathom.core/keys [path] :as env})
Find the closest parent key that's not a placeholder key.
Find the closest parent key that's not a placeholder key.
(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]
:as env})
(join entity
{:keys [ast query] :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 parsed 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 parsed 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-children? {:keys [query]} v)
Children should join when there is a query, unless the value is marked as final.
Children should join when there is a query, unless the value is marked as final.
(join-map env m)
Runs the current subquery against the items of the given collection.
Runs the current subquery against the items of the given collection.
(join-seq {:com.wsscode.pathom.parser/keys [parallel?] :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.
(join-seq-parallel {:keys [query]
:com.wsscode.pathom.core/keys [entity-path-cache
parent-query]
:as env}
coll)
(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 env 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.
(lift-placeholders-ast env ast)
This will lift the AST from placeholders to the same level of the query, as if there was not placeholders in it.
This will lift the AST from placeholders to the same level of the query, as if there was not placeholders in it.
(map->shape-descriptor m)
Convert Map to shape descriptor format
Convert Map to shape descriptor format
(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.
(map-select map selection)
Starting from a map, do a EQL selection on that map. Think of this function as
a power up version of select-keys, but supporting nested selections and placeholders
using the default >
namespace.
Example: (p/map-select {:foo "bar" :deep {:a 1 :b 2}} [{:deep [:a]}]) => {:deep {:a 1}}
Starting from a map, do a EQL selection on that map. Think of this function as a power up version of select-keys, but supporting nested selections and placeholders using the default `>` namespace. Example: (p/map-select {:foo "bar" :deep {:a 1 :b 2}} [{:deep [:a]}]) => {:deep {:a 1}}
(normalize-query-variables query)
Converts ident values and param values to ::p/var.
Converts ident values and param values to ::p/var.
(normalize-request input)
Normalize a remote interface input. In case of vector it makes a map. Otherwise returns as is.
Normalize a remote interface input. In case of vector it makes a map. Otherwise returns as is.
(parallel-parser settings)
Create a new pathom parallel parser, this parser is capable of coordinating parallel data fetch. This also works as an async parser and will handle core async channels properly.
Options to tune the parser:
::p/env - Use this key to provide a default environment for the parser. This is a sugar to use the p/env-plugin.
::p/mutate - A mutate function that will be called to run mutations, this function must have the signature: (mutate env key params)
::p/plugins - A vector with plugins.
::p/async-request-cache-ch-size - Pathom uses internally a queue to avoid concurrency issues with concurrency, each request gets its own channel, so you can consider this size needs to accommodate the max parallelism for a single query. Default: 1024
::pp/external-wait-ignore-timeout - Sometimes external waits get stuck because a concurrency problem, this timeout will ignore external waits after some time so the request can go on. Default: 3000
::pp/max-key-iterations - there is a loop that happens when processing attributes in parallel, this loop will cause multiple iterations to happen in order for a single attribute to be processed, but in some conditions this loop can go indefinitely, to prevent this situation this option allows to control the max number of iterations, after that it will give up on processing that attribute. Default: 10
::pp/key-process-timeout - Max time allowed to run the full query. This is a cascading timeout, the first level will have the total amount. Default: 60000
::pp/processing-recheck-timer - Periodic time to run a checker to verify no parts are stuck during the processing, when nil the feature is disabled. Default: nil
Create a new pathom parallel parser, this parser is capable of coordinating parallel data fetch. This also works as an async parser and will handle core async channels properly. Options to tune the parser: ::p/env - Use this key to provide a default environment for the parser. This is a sugar to use the p/env-plugin. ::p/mutate - A mutate function that will be called to run mutations, this function must have the signature: (mutate env key params) ::p/plugins - A vector with plugins. ::p/async-request-cache-ch-size - Pathom uses internally a queue to avoid concurrency issues with concurrency, each request gets its own channel, so you can consider this size needs to accommodate the max parallelism for a single query. Default: 1024 ::pp/external-wait-ignore-timeout - Sometimes external waits get stuck because a concurrency problem, this timeout will ignore external waits after some time so the request can go on. Default: 3000 ::pp/max-key-iterations - there is a loop that happens when processing attributes in parallel, this loop will cause multiple iterations to happen in order for a single attribute to be processed, but in some conditions this loop can go indefinitely, to prevent this situation this option allows to control the max number of iterations, after that it will give up on processing that attribute. Default: 10 ::pp/key-process-timeout - Max time allowed to run the full query. This is a cascading timeout, the first level will have the total amount. Default: 60000 ::pp/processing-recheck-timer - Periodic time to run a checker to verify no parts are stuck during the processing, when nil the feature is disabled. Default: nil
(params env)
Get params from env, always returns a map.
Get params from env, always returns a map.
(parser settings)
Create a new pathom serial parser, this parser is capable of waiting for core.async to continue processing, allowing async operations to happen during the parsing.
Options to tune the parser:
::p/env - Use this key to provide a default environment for the parser. This is a sugar to use the p/env-plugin.
::p/mutate - A mutate function that will be called to run mutations, this function must have the signature: (mutate env key params)
::p/plugins - A vector with plugins.
Create a new pathom serial parser, this parser is capable of waiting for core.async to continue processing, allowing async operations to happen during the parsing. Options to tune the parser: ::p/env - Use this key to provide a default environment for the parser. This is a sugar to use the p/env-plugin. ::p/mutate - A mutate function that will be called to run mutations, this function must have the signature: (mutate env key params) ::p/plugins - A vector with plugins.
(path-without-placeholders {:com.wsscode.pathom.core/keys [path] :as env})
(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-key? {:com.wsscode.pathom.core/keys [placeholder-prefixes]} k)
(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.
(pre-process-parser-plugin f)
Helper to create a plugin that can view/modify the env/tx of a top-level request. f - (fn [{:keys [env tx]}] {:env new-env :tx new-tx}) If the function returns no env or tx, then the parser will not be called (aborts the parse)
Helper to create a plugin that can view/modify the env/tx of a top-level request. f - (fn [{:keys [env tx]}] {:env new-env :tx new-tx}) If the function returns no env or tx, then the parser will not be called (aborts the parse)
(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.
(query-id query)
Generates a consistent hash from the query. The query first goes to a process to remove any variables from idents and params, then we get the Clojure hash of it. You can use this to save information about a query that can be used to correlate with the query later.
Generates a consistent hash from the query. The query first goes to a process to remove any variables from idents and params, then we get the Clojure hash of it. You can use this to save information about a query that can be used to correlate with the query later.
(raise-errors data)
Extract errors from the data root and inject those in the same level where the error item is present. For example:
{:query {:item :com.wsscode.pathom/reader-error} :com.wsscode.pathom.core/errors {[:query :item] {:error "some error"}}}
Is turned into:
{:query {:item :com.wsscode.pathom/reader-error :com.wsscode.pathom.core/errors {:item {:error "some error"}}}
This makes easier to reach for the error when rendering the UI.
Use it e.g. via [[p/post-process-parser-plugin]], after the [[p/error-handler-plugin]].
Extract errors from the data root and inject those in the same level where the error item is present. For example: {:query {:item :com.wsscode.pathom/reader-error} :com.wsscode.pathom.core/errors {[:query :item] {:error "some error"}}} Is turned into: {:query {:item :com.wsscode.pathom/reader-error :com.wsscode.pathom.core/errors {:item {:error "some error"}}} This makes easier to reach for the error when rendering the UI. Use it e.g. via [[p/post-process-parser-plugin]], after the [[p/error-handler-plugin]].
(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
(reader env)
Like read-from, pulling reader from environment.
Like read-from, pulling reader from environment.
DEPRECATED not required anymore, this was integrated in the main engine.
DEPRECATED not required anymore, this was integrated in the main engine.
(reset-parallel-env env)
If you are doing a recursive call to the parser inside a resolver and using parallel parser, you need to pass the env though this function to avoid issues.
Example:
(pc/defresolver internal-recursive [{:keys [parser] :as env} input] {::result (parser (p/reset-parallel-env env) [::sub-query])})
If you are doing a recursive call to the parser inside a resolver and using parallel parser, you need to pass the env though this function to avoid issues. Example: (pc/defresolver internal-recursive [{:keys [parser] :as env} input] {::result (parser (p/reset-parallel-env env) [::sub-query])})
(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})
Recursively 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]
Recursively 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