(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`.
(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]
:com.wsscode.pathom.core/keys [processing-sequence]
:or {max-resolver-weight 3600000}
:as env})
Like reader2, but supports async values on resolver return.
Like reader2, but supports async values 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
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 instrospection in 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 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 instrospection in tools like Pathom Viz and Fulcro Inspect.
(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 sym arglist config & body)
(defresolver &form &env sym arglist config & body)
(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]
:or {mutation-join-globals []}
:as env}
sym'
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]
:or {mutation-join-globals []}
:as env}
sym'
input)
Async mutate function to integrate connect mutations to pathom parser.
Async mutate function to integrate connect mutations to pathom parser.
(mutation sym 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.connect/keys [plan]
:as env})
Returns a set containing all attributes that are expected to participate in path resolution in the current parent 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.
This function is intended to be called during resolver code.
Returns a set containing all attributes that are expected to participate in path resolution in the current parent 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. 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})
(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 options resolve)
Helper to return a resolver map
Helper to return a resolver map
(resolver-data env-or-indexes sym)
Get resolver map information in env from the resolver sym.
Get resolver map information in env from the resolver sym.
(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.
(sort-resolvers {:com.wsscode.pathom.core/keys [request-cache]} resolvers e)
(update-resolver-weight {:com.wsscode.pathom.connect/keys [resolver-weights]}
resolver
&
args)
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close