Liking cljdoc? Tell your friends :D

com.wsscode.pathom.connect


addclj/s

(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`.
sourceraw docstring

add-mutationclj/s

(add-mutation indexes
              sym
              {:com.wsscode.pathom.connect/keys [params output] :as data})
source

alias-resolverclj/s

(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
sourceraw docstring

alias-resolver2clj/s

(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.
sourceraw docstring

all-async-readersclj/s

source

all-parallel-readersclj/s

source

all-readersclj/s

source

all-values-valid?clj/s

(all-values-valid? m input)
source

async-pick-resolverclj/s

(async-pick-resolver
  {:com.wsscode.pathom.connect/keys [indexes dependency-track] :as env})

DEPRECATED

DEPRECATED
sourceraw docstring

async-readerclj/s

(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.
sourceraw docstring

async-reader2clj/s

(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.
sourceraw docstring

atom-withclj/s

(atom-with spec)
source

attr-alias-nameclj/s

(attr-alias-name from to)
source

batch-resolverclj/s

(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.
sourceraw docstring

batch-restore-sortclj/s

(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.
sourceraw docstring

call-resolverclj/s

(call-resolver {:com.wsscode.pathom.connect/keys [pool-chan] :as env} entity)
source

call-resolver*clj/s

(call-resolver* {:com.wsscode.pathom.connect/keys [resolver-dispatch
                                                   resolver-weights]
                 :or {resolver-dispatch default-resolver-dispatch}
                 :as env}
                entity)
source

compute-pathsclj/s

(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).
sourceraw docstring

compute-paths*clj/s

(compute-paths* index-oir keys bad-keys attr pending)
source

connect-pluginclj/s

(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 recommneded)

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
`::pc/pool-chan` - override the thread pool, use `nil` to disable thread pool feature (not recommneded)

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.
sourceraw docstring

connect-resolversclj/s

source

create-thread-poolclj

(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).
sourceraw docstring

data->shapeclj/s

(data->shape data)

Helper function to transform a data into an output shape.

Helper function to transform a data into an output shape.
sourceraw docstring

decrease-path-costsclj/s

(decrease-path-costs {:com.wsscode.pathom.connect/keys
                        [resolver-weights resolver-weight-decrease-amount]
                      :or {resolver-weight-decrease-amount 1}}
                     plan)
source

default-resolver-dispatchclj/s

(default-resolver-dispatch {{:com.wsscode.pathom.connect/keys [sym]
                             :as resolver}
                              :com.wsscode.pathom.connect/resolver-data
                            :as env}
                           entity)
source

default-sort-planclj/s

(default-sort-plan env plan)
source

defmutationclj/s≠macro

clj
(defmutation sym arglist config & body)
cljs
(defmutation &form &env sym arglist config & body)
source (clj)source (cljs)

defresolverclj/s≠macro

clj
(defresolver sym arglist config & body)
cljs
(defresolver &form &env sym arglist config & body)
source (clj)source (cljs)

discover-attrsclj/s

(discover-attrs {:com.wsscode.pathom.connect/keys [index-io cache] :as index}
                ctx)
source

group-input-indexesclj/s

(group-input-indexes inputs)
source

ident-readerclj/s

(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.
sourceraw docstring

index-attributesclj/s

(index-attributes {:com.wsscode.pathom.connect/keys [sym input output]})
source

index-explorer-resolverclj/s

source

index-mergerclj/smultimethod

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.
sourceraw docstring

index-readerclj/s

source

indexed-identclj/s

(indexed-ident {:com.wsscode.pathom.connect/keys [indexes] :as env})
source

indexes-resolverclj/s

source

merge-growclj/s

(merge-grow a b)
source

merge-indexesclj/s

(merge-indexes ia ib)
source

merge-ioclj/s

(merge-io a b)

Merge ::index-io maps.

Merge ::index-io maps.
sourceraw docstring

merge-oirclj/s

(merge-oir a b)

Merge ::index-oir maps.

Merge ::index-oir maps.
sourceraw docstring

mutateclj/s

(mutate {:com.wsscode.pathom.connect/keys [indexes mutate-dispatch
                                           mutation-join-globals]
         :keys [query]
         :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.
sourceraw docstring

mutate-asyncclj/s

(mutate-async {:com.wsscode.pathom.connect/keys [indexes mutate-dispatch
                                                 mutation-join-globals]
               :keys [query]
               :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.
sourceraw docstring

mutationclj/s

(mutation sym {:com.wsscode.pathom.connect/keys [transform] :as options} mutate)

Helper to return a mutation map

Helper to return a mutation map
sourceraw docstring

mutation-dataclj/s

(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.
sourceraw docstring

mutation-dispatchclj/s

(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.
sourceraw docstring

mutation-dispatch-embeddedclj/s

(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.
sourceraw docstring

mutation-factoryclj/s

(mutation-factory mm idx)
source

normalized-childrenclj/s

(normalized-children {:keys [children]})
source

open-ident-readerclj/s

(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.
sourceraw docstring

output->providesclj/s

(output->provides output)
source

output-providesclj/s

(output-provides query)
source

output-provides*clj/s

(output-provides* {:keys [key children]})
source

parallel-batchclj/s

(parallel-batch {:com.wsscode.pathom.core/keys [processing-sequence path
                                                entity-path-cache]
                 :as env})
source

parallel-batch-errorclj/s

(parallel-batch-error {:com.wsscode.pathom.core/keys [processing-sequence]
                       :as env}
                      e)
source

parallel-readerclj/s

(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})
source

path-costclj/s

(path-cost {:com.wsscode.pathom.connect/keys [resolver-weights]
            :com.wsscode.pathom.core/keys [request-cache]
            :as env}
           path)
source

pick-resolverclj/s

(pick-resolver {:com.wsscode.pathom.connect/keys [indexes dependency-track]
                :as env})

DEPRECATED

DEPRECATED
sourceraw docstring

plan->providesclj/s

(plan->provides env plan)
source

plan->resolversclj/s

(plan->resolvers plan)
source

project-parent-query-attributesclj/s

(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
sourceraw docstring

project-query-attributesclj/s

(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.
sourceraw docstring

readerclj/s

(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.
sourceraw docstring

reader-compute-planclj/s

(reader-compute-plan env failed-resolvers)
source

reader2clj/s

(reader2 {:com.wsscode.pathom.connect/keys [indexes max-resolver-weight]
          :com.wsscode.pathom.core/keys [processing-sequence]
          :or {max-resolver-weight 3600000}
          :as env})
source

registerclj/s

(register indexes item-or-items)

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
    )
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
        )
sourceraw docstring

reprocess-indexclj/s

(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
sourceraw docstring

resolve-planclj/s

(resolve-plan {:com.wsscode.pathom.connect/keys [indexes sort-plan] :as env})
source

resolverclj/s

(resolver sym
          {:com.wsscode.pathom.connect/keys [transform] :as options}
          resolve)

Helper to return a resolver map

Helper to return a resolver map
sourceraw docstring

resolver->outputclj/s

(resolver->output env resolver-sym)
source

resolver-dataclj/s

(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.
sourceraw docstring

resolver-dispatchclj/s

(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.
sourceraw docstring

resolver-dispatch-embeddedclj/s

(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.
sourceraw docstring

resolver-factoryclj/s

(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.
sourceraw docstring

resolver-weights-resolverclj/s

source

resolver-weights-resolversclj/s

source

resolver-weights-sorted-resolverclj/s

source

sort-resolversclj/s

(sort-resolvers {:com.wsscode.pathom.core/keys [request-cache]} resolvers e)
source

split-good-bad-keysclj/s

(split-good-bad-keys entity)
source

step-weightclj/s

(step-weight value new-value)
source

transform-auto-batchclj/s

(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.
sourceraw docstring

transform-batch-resolverclj/s

(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.
sourceraw docstring

update-resolver-weightclj/s

(update-resolver-weight {:com.wsscode.pathom.connect/keys [resolver-weights]}
                        resolver
                        &
                        args)
source

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close