(add indexes sym)
(add indexes sym sym-data)
Low level function to add resolvers to the index. This function adds the resolver configuration to the index set, adds the resolver to the ::pc/index-resolvers, add the output to input index in the ::pc/index-oir and the reverse index for auto-complete to the index ::pc/index-io.
This is a low level function, for adding to your index prefer using pc/register
.
Low level function to add resolvers to the index. This function adds the resolver configuration to the index set, adds the resolver to the ::pc/index-resolvers, add the output to input index in the ::pc/index-oir and the reverse index for auto-complete to the index ::pc/index-io. This is a low level function, for adding to your index prefer using `pc/register`.
(add-mutation indexes
sym
{:com.wsscode.pathom.connect/keys [params output] :as data})
(alias-resolver from to)
Create a resolver that will convert property from
to a property to
with
the same value. This only creates the alias in one direction
Create a resolver that will convert property `from` to a property `to` with the same value. This only creates the alias in one direction
(alias-resolver2 from to)
Like alias-resolver, but returns a vector containing the alias in both directions.
Like alias-resolver, but returns a vector containing the alias in both directions.
(async-pick-resolver
{:com.wsscode.pathom.connect/keys [indexes dependency-track] :as env})
DEPRECATED
DEPRECATED
(async-reader {:com.wsscode.pathom.connect/keys [indexes]
:as env
:com.wsscode.pathom.core/keys [processing-sequence]})
DEPRECATED: use async-reader2
Like reader, but supports async values on resolver return.
DEPRECATED: use async-reader2 Like reader, but supports async values on resolver return.
(async-reader2 {:com.wsscode.pathom.connect/keys [indexes max-resolver-weight]
:or {max-resolver-weight 3600000}
:as env})
Works in the same way reader2
, but supports async values (core.async channels)
on resolver return.
Works in the same way `reader2`, but supports async values (core.async channels) on resolver return.
(batch-resolver multi-fn)
(batch-resolver single-fn multi-fn)
Return a resolver that will dispatch to single-fn when the input is a single value, and multi-fn when multiple inputs are provided (on batch cases).
Many times the implementation for the single can be the same as the multi, getting the first item, and if you provide only one function (the multi-fn) we will setup the single one automatically running the multi and returning the first result.
Return a resolver that will dispatch to single-fn when the input is a single value, and multi-fn when multiple inputs are provided (on batch cases). Many times the implementation for the single can be the same as the multi, getting the first item, and if you provide only one function (the multi-fn) we will setup the single one automatically running the multi and returning the first result.
(batch-restore-sort {:com.wsscode.pathom.connect/keys [inputs key
batch-default]}
items)
Sorts output list to match input list.
When doing batch requests you must return a vector in the same order respective to the order of inputs. Many times when calling an external API sending a list of ids the returned list doesn't always garantee input order. To fix these cases this function can restore the order. Example:
(fn batch-resolver [env inputs]
; inputs => [{:my.entity/id 1} {:my.entity/id 2}]
(batch-restore-sort {::inputs inputs
::key :my.entity/id}
[{:my.entity/id 2
:my.entity/color :my.entity.color/green}
{:my.entity/id 1
:my.entity/color :my.entity.color/purple}])
; => [{:my.entity/id 1
; :my.entity/color :my.entity.color/purple}
; {:my.entity/id 2
; :my.entity/color :my.entity.color/green}]
You can provide a ::batch-default function to fill in for missing items on the output. The default function will take the respective input and must return a map containing any data you want to add, usually some nil keys to declare that value should not require further lookup.
Sorts output list to match input list. When doing batch requests you must return a vector in the same order respective to the order of inputs. Many times when calling an external API sending a list of ids the returned list doesn't always garantee input order. To fix these cases this function can restore the order. Example: (fn batch-resolver [env inputs] ; inputs => [{:my.entity/id 1} {:my.entity/id 2}] (batch-restore-sort {::inputs inputs ::key :my.entity/id} [{:my.entity/id 2 :my.entity/color :my.entity.color/green} {:my.entity/id 1 :my.entity/color :my.entity.color/purple}]) ; => [{:my.entity/id 1 ; :my.entity/color :my.entity.color/purple} ; {:my.entity/id 2 ; :my.entity/color :my.entity.color/green}] You can provide a ::batch-default function to fill in for missing items on the output. The default function will take the respective input and must return a map containing any data you want to add, usually some nil keys to declare that value should not require further lookup.
(call-resolver {:com.wsscode.pathom.connect/keys [pool-chan] :as env} entity)
(call-resolver* {:com.wsscode.pathom.connect/keys [resolver-dispatch
resolver-weights]
:or {resolver-dispatch default-resolver-dispatch}
:as env}
entity)
(compute-paths index-oir keys bad-keys attr)
This function will return a set of possible paths given a set of available keys to reach some attribute. You also send a set of bad keys, bad keys mean information you cannot use (maybe they already got an error, or you known will not be available).
This function will return a set of possible paths given a set of available keys to reach some attribute. You also send a set of bad keys, bad keys mean information you cannot use (maybe they already got an error, or you known will not be available).
(connect-plugin)
(connect-plugin {:com.wsscode.pathom.connect/keys [indexes] :as env})
This plugin facilitates the connect setup in a parser. It works by wrapping the parser, it setups the connect resolver and mutation dispatch using the embedded dispatchers (check resolver map format in the book for more details). It also sets up the resolver weights for load balacing calculation. Here are the available options to configure the plugin:
::pc/indexes
- provide an index atom to be used, otherwise the plugin will create one
::pc/register
- a resolver, mutation or sequence of resolvers/mutations to register in
the index
::pc/pool-chan
- override the thread pool, use nil
to disable thread pool feature (not recommended)
This plugin also looks for the key ::pc/register
in the other plugins used in the
parser configuration, this enable plugins to provide resolvers/mutations to be available
in your connect system.
By default this plugin will also register resolvers to provide the index itself, if
you for some reason need to hide it you can dissoc the ::pc/register
from the output
and they will not be available, but consider that doing so you lose the ability to
have introspection tools like Pathom Viz and Fulcro Inspect.
This plugin facilitates the connect setup in a parser. It works by wrapping the parser, it setups the connect resolver and mutation dispatch using the embedded dispatchers (check resolver map format in the book for more details). It also sets up the resolver weights for load balacing calculation. Here are the available options to configure the plugin: `::pc/indexes` - provide an index atom to be used, otherwise the plugin will create one `::pc/register` - a resolver, mutation or sequence of resolvers/mutations to register in the index `::pc/pool-chan` - override the thread pool, use `nil` to disable thread pool feature (not recommended) This plugin also looks for the key `::pc/register` in the other plugins used in the parser configuration, this enable plugins to provide resolvers/mutations to be available in your connect system. By default this plugin will also register resolvers to provide the index itself, if you for some reason need to hide it you can dissoc the `::pc/register` from the output and they will not be available, but consider that doing so you lose the ability to have introspection tools like Pathom Viz and Fulcro Inspect.
(constantly-resolver {:com.wsscode.pathom.connect/keys [attribute sym]
:keys [value]})
(constantly-resolver attribute value)
Create a simple resolver that always return value
for attribute
.
Create a simple resolver that always return `value` for `attribute`.
(create-thread-pool ch)
(create-thread-pool thread-count ch)
Returns a channel that will enqueue and execute messages using a thread pool.
The returned channel here can be used as the ::pc/pool-chan argument to be used for executing resolvers (and avoid blocking the limited go block threads).
You must provide the channel ch that will be used to listen for commands. You may provide a thread-count, if you do a fixed size thread will be created and shared across all calls to the parser. In case you don't provide the thread-count the threads will be managed by core.async built-in thread pool for threads (not the same as the go block threads).
Returns a channel that will enqueue and execute messages using a thread pool. The returned channel here can be used as the ::pc/pool-chan argument to be used for executing resolvers (and avoid blocking the limited go block threads). You must provide the channel ch that will be used to listen for commands. You may provide a thread-count, if you do a fixed size thread will be created and shared across all calls to the parser. In case you don't provide the thread-count the threads will be managed by core.async built-in thread pool for threads (not the same as the go block threads).
(data->shape data)
Helper function to transform a data into an output shape.
Helper function to transform a data into an output shape.
(decrease-path-costs {:com.wsscode.pathom.connect/keys
[resolver-weights resolver-weight-decrease-amount]
:or {resolver-weight-decrease-amount 1}}
plan)
(default-resolver-dispatch {{:com.wsscode.pathom.connect/keys [sym]
:as resolver}
:com.wsscode.pathom.connect/resolver-data
:as env}
entity)
(defmutation sym arglist config & body)
(defmutation &form &env sym arglist config & body)
(defresolver & args)
(defresolver &form &env & args)
(discover-attrs {:com.wsscode.pathom.connect/keys [index-io cache] :as index}
ctx)
(ident-reader env)
Reader for idents on connect, this reader will make a join to the ident making the context have that ident key and value. For example the ident [:user/id 123] will make a join to a context {:user/id 123}. This reader will continue if connect doesn't have a path to respond to that ident.
This reader also supports params to add more context besides the entity value. To use
that send the :pathom/context
param with the join, as in:
[{([:user/id 123] {:pathom/context {:user/foo "bar"}}) [:user/name]}]
In the previous case, the context will be the merge between the identity and the context, {:user/id 123 :user/foo "bar"} in this case.
Reader for idents on connect, this reader will make a join to the ident making the context have that ident key and value. For example the ident [:user/id 123] will make a join to a context {:user/id 123}. This reader will continue if connect doesn't have a path to respond to that ident. This reader also supports params to add more context besides the entity value. To use that send the `:pathom/context` param with the join, as in: [{([:user/id 123] {:pathom/context {:user/foo "bar"}}) [:user/name]}] In the previous case, the context will be the merge between the identity and the context, {:user/id 123 :user/foo "bar"} in this case.
This is an extensible gateway so you can define different strategies for merging different kinds of indexes.
This is an extensible gateway so you can define different strategies for merging different kinds of indexes.
(mutate {:com.wsscode.pathom.connect/keys [indexes mutate-dispatch
mutation-join-globals]
:keys [query ast]
:or {mutation-join-globals []}
:as env}
sym'
{:keys [pathom/context] :as input})
Sync mutate function to integrate connect mutations to pathom parser.
Sync mutate function to integrate connect mutations to pathom parser.
(mutate-async {:com.wsscode.pathom.connect/keys [indexes mutate-dispatch
mutation-join-globals]
:keys [query ast]
:or {mutation-join-globals []}
:as env}
sym'
{:keys [pathom/context] :as input})
Async mutate function to integrate connect mutations to pathom parser.
Async mutate function to integrate connect mutations to pathom parser.
(mutation sym {:com.wsscode.pathom.connect/keys [transform] :as options} mutate)
Helper to return a mutation map
Helper to return a mutation map
(mutation-data env-or-indexes sym)
Get mutation map information in env from the resolver sym.
Get mutation map information in env from the resolver sym.
(mutation-dispatch env _)
Helper method that extract key from ast symbol from env. It's recommended to use as a dispatch method for creating multi-methods for mutation dispatch.
Helper method that extract key from ast symbol from env. It's recommended to use as a dispatch method for creating multi-methods for mutation dispatch.
(mutation-dispatch-embedded {:com.wsscode.pathom.connect/keys [indexes] :as env}
entity)
This dispatch method will fire the mutation by looking at the ::pc/mutate key in the mutation map details.
This dispatch method will fire the mutation by looking at the ::pc/mutate key in the mutation map details.
(open-ident-reader env)
Like ident-reader, but ident key doesn't have to be in the index, this will respond to any ident join. Also supports extra context with :pathom/context param.
Like ident-reader, but ident key doesn't have to be in the index, this will respond to any ident join. Also supports extra context with :pathom/context param.
(parallel-batch {:com.wsscode.pathom.core/keys [processing-sequence path
entity-path-cache]
:as env})
(parallel-batch-error {:com.wsscode.pathom.core/keys [processing-sequence]
:as env}
e)
(parallel-reader {:com.wsscode.pathom.connect/keys [indexes max-resolver-weight]
:com.wsscode.pathom.core/keys [processing-sequence]
:com.wsscode.pathom.parser/keys [waiting]
:or {max-resolver-weight 3600000}
:as env})
(path-cost {:com.wsscode.pathom.connect/keys [resolver-weights]
:com.wsscode.pathom.core/keys [request-cache]
:as env}
path)
(pick-resolver {:com.wsscode.pathom.connect/keys [indexes dependency-track]
:as env})
DEPRECATED
DEPRECATED
(project-parent-query-attributes {:com.wsscode.pathom.core/keys [parent-query]
:as env})
Project query attributes for the parent query. See
Project query attributes for the parent query. See
(project-query-attributes env query)
Returns a set containing all attributes that are expected to participate in path resolution given a query. This function is intended to help dynamic resolvers that need to know which attributes are required before doing a call to the information source. For example, we never want to issue more than one GraphQL query to the same server at the same query level, but if we just look at the parent query is not enough; that's because some of the attributes might require other attributes to be fetched, this function will scan the attributes and figure everything that is required so you can issue a single request.
Please note the attribute calculation might depend on the data currently available
in the ::p/entity
, if you are calculating attributes for a different context
you might want to replace some of the entity data.
This function is intended to be called during resolver code.
Returns a set containing all attributes that are expected to participate in path resolution given a query. This function is intended to help dynamic resolvers that need to know which attributes are required before doing a call to the information source. For example, we never want to issue more than one GraphQL query to the same server at the same query level, but if we just look at the parent query is not enough; that's because some of the attributes might require other attributes to be fetched, this function will scan the attributes and figure everything that is required so you can issue a single request. Please note the attribute calculation might depend on the data currently available in the `::p/entity`, if you are calculating attributes for a different context you might want to replace some of the entity data. This function is intended to be called during resolver code.
(reader {:com.wsscode.pathom.connect/keys [indexes]
:as env
:com.wsscode.pathom.core/keys [processing-sequence]})
DEPRECATED: use reader2 instead
Connect reader, this reader will lookup the given key in the index to process it, in case the resolver input can't be satisfied it will do a recursive lookup trying to find the next input.
I recommend you switch to reader2, which instead plans ahead of time the full path it will need to cover to go from the current data to the requested attribute.
DEPRECATED: use reader2 instead Connect reader, this reader will lookup the given key in the index to process it, in case the resolver input can't be satisfied it will do a recursive lookup trying to find the next input. I recommend you switch to reader2, which instead plans ahead of time the full path it will need to cover to go from the current data to the requested attribute.
(reader2 {:com.wsscode.pathom.connect/keys [indexes max-resolver-weight]
:com.wsscode.pathom.core/keys [processing-sequence]
:or {max-resolver-weight 3600000}
:as env})
Recommended reader to use with Pathom serial parser.
This reader uses the connect index to compute a EQL property requirement.
The process goes as:
This only handles sync process, if you return a core.async channel, the channel itself
will be the response. If you need to handle async use async-reader2
.
Recommended reader to use with Pathom serial parser. This reader uses the connect index to compute a EQL property requirement. The process goes as: - find possible paths to realize the attribute, given the current available data, generating a plan - executes the plan - in case a resolver fails (due to exception, or missing required data) the reader will try to backtrack and execute another path (if there is one available). This only handles sync process, if you return a core.async channel, the channel itself will be the response. If you need to handle async use `async-reader2`.
(reader3 {:com.wsscode.pathom.connect/keys [indexes max-resolver-weight
reader3-computed-plans]
:com.wsscode.pathom.core/keys [async-parser?]
:or {max-resolver-weight 3600000}
:as env})
(reader3-all-requires-ready? env
{:com.wsscode.pathom.connect.planner/keys
[requires]})
(reader3-node-log! {:com.wsscode.pathom.connect/keys [run-plan*] :as env}
{:com.wsscode.pathom.connect.planner/keys [node-id]}
event)
(reader3-prepare-ast {:com.wsscode.pathom.core/keys [parent-query] :as env})
Prepare AST from parent query. This will lift placeholder nodes, convert query to AST and remove children keys that are already present in the current entity.
Prepare AST from parent query. This will lift placeholder nodes, convert query to AST and remove children keys that are already present in the current entity.
(reader3-run-and-node env plan node)
Execute an AND node.
Execute an AND node.
(reader3-run-and-node-async env
plan
{:com.wsscode.pathom.connect.planner/keys [run-and]
:as node})
(reader3-run-and-node-sync env
plan
{:com.wsscode.pathom.connect.planner/keys [run-and]
:as node})
(reader3-run-next-node env
plan
{:com.wsscode.pathom.connect.planner/keys [run-next]})
(reader3-run-or-node env plan node)
Execute an OR node.
Execute an OR node.
(reader3-run-or-node-async env
plan
{:com.wsscode.pathom.connect.planner/keys [run-or]
:as or-node})
(reader3-run-or-node-sync env
plan
{:com.wsscode.pathom.connect.planner/keys [run-or]
:as or-node})
(reader3-run-resolver-node {:com.wsscode.pathom.connect/keys [indexes]
:com.wsscode.pathom.core/keys [async-parser?]
:as env}
plan
{:com.wsscode.pathom.connect/keys [sym]
:com.wsscode.pathom.connect.planner/keys [input
params]
:as node})
Call a run graph node resolver and execute it.
Call a run graph node resolver and execute it.
(register indexes item-or-items)
Updates the index by registering the given resolver or mutation (lets call it item), an item can be:
The sequence version can have nested sequences, they will be recursively add.
Examples of possible usages:
(-> {} ; blank index
(pc/register one-resolver) ; single resolver
(pc/register one-mutation) ; single mutation
(pc/register [one-resolver one-mutation]) ; sequence of resolvers/mutations
(pc/register [[resolver1 resolver2] [resolver3 mutation]]) ; nested sequences
(pc/register [[resolver1 resolver2] resolver-out [resolver3 mutation]]) ; all mixed
)
Updates the index by registering the given resolver or mutation (lets call it item), an item can be: 1. a resolver map 2. a mutation map 3. a sequence with items The sequence version can have nested sequences, they will be recursively add. Examples of possible usages: (-> {} ; blank index (pc/register one-resolver) ; single resolver (pc/register one-mutation) ; single mutation (pc/register [one-resolver one-mutation]) ; sequence of resolvers/mutations (pc/register [[resolver1 resolver2] [resolver3 mutation]]) ; nested sequences (pc/register [[resolver1 resolver2] resolver-out [resolver3 mutation]]) ; all mixed )
(reprocess-index {:com.wsscode.pathom.connect/keys [index-resolvers]})
This will use the ::index-resolvers to re-build the index. You might need that if in development you changed some definitions and got in a dirty state somehow
This will use the ::index-resolvers to re-build the index. You might need that if in development you changed some definitions and got in a dirty state somehow
(resolve-plan {:com.wsscode.pathom.connect/keys [indexes sort-plan] :as env})
(resolver sym
{:com.wsscode.pathom.connect/keys [transform] :as options}
resolve)
Helper to return a resolver map
Helper to return a resolver map
(resolver-dispatch env)
(resolver-dispatch env _)
Helper method that extract resolver symbol from env. It's recommended to use as a dispatch method for creating multi-methods for resolver dispatch.
Helper method that extract resolver symbol from env. It's recommended to use as a dispatch method for creating multi-methods for resolver dispatch.
(resolver-dispatch-embedded {{:com.wsscode.pathom.connect/keys [resolve sym]}
:com.wsscode.pathom.connect/resolver-data
:as env}
entity)
This dispatch method will fire the resolver by looking at the ::pc/resolve key in the resolver map details.
This dispatch method will fire the resolver by looking at the ::pc/resolve key in the resolver map details.
(resolver-factory mm idx)
Given multi-method mm and index atom idx, returns a function with the given signature: [sym config f], the function will be add to the mm and will be indexed using config as the config params for connect/add.
Given multi-method mm and index atom idx, returns a function with the given signature: [sym config f], the function will be add to the mm and will be indexed using config as the config params for connect/add.
(serial-cache-resolver-call {:com.wsscode.pathom.core/keys [processing-sequence]
{:com.wsscode.pathom.connect/keys [sym batch?]}
:com.wsscode.pathom.connect/resolver-data
:as env}
e)
(serial-resolver-call-batch {:com.wsscode.pathom.core/keys [processing-sequence]
{:com.wsscode.pathom.connect/keys [sym input]}
:com.wsscode.pathom.connect/resolver-data
:as env}
e)
(single-attr-resolver from to f)
Apply fn f
to input from
and spits the result with the name to
.
f
receives a single argument, which is the input value from from
.
Apply fn `f` to input `from` and spits the result with the name `to`. `f` receives a single argument, which is the input value from `from`.
(single-attr-resolver2 from to f)
Similar single-attr-resolver, but f
receives two arguments, env
and the input.
Similar single-attr-resolver, but `f` receives two arguments, `env` and the input.
(sort-resolvers {:com.wsscode.pathom.core/keys [request-cache]} resolvers e)
(transform-auto-batch n)
Given a resolver that implements the single item case, wrap it implementing a batch
resolver that will make a batch by running many in parallel, using n
as the concurrency
number.
Given a resolver that implements the single item case, wrap it implementing a batch resolver that will make a batch by running many in parallel, using `n` as the concurrency number.
(transform-batch-resolver resolver)
Given a resolver that implements the many case, return one that also supports the single case by running the many and taking the first result out.
Given a resolver that implements the many case, return one that also supports the single case by running the many and taking the first result out.
(update-resolver-weight {:com.wsscode.pathom.connect/keys [resolver-weights]}
resolver
&
args)
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close