Liking cljdoc? Tell your friends :D

com.wsscode.pathom3.connect.operation


?clj/s

(? attr)

Make an attribute optional

Make an attribute optional
sourceraw docstring

defmutationclj/smacro

(defmutation name docstring? arglist options? & body)

Defines a new Pathom mutation. The syntax of this macro is similar to defresolver, But where defresolver takes input, defmutation uses as ::params.

Defines a new Pathom mutation. The syntax of this macro is similar to defresolver,
But where `defresolver` takes input, `defmutation` uses as ::params.
sourceraw docstring

defresolverclj/smacro

(defresolver name docstring? arglist options? & body)

Defines a new Pathom resolver.

Resolvers are the central abstraction around Pathom, a resolver is a function that contains some annotated information and follow a few rules:

  1. The resolver input must be a map, so the input information is labelled.
  2. A resolver must return a map, so the output information is labelled.
  3. A resolver also receives a separated map containing the environment information.

Here are some examples of how you can use the defresolver syntax to define resolvers:

The verbose example:

(pco/defresolver song-by-id [env {:acme.song/keys [id]}]
  {::pco/input     [:acme.song/id]
   ::pco/output    [:acme.song/title :acme.song/duration :acme.song/tone]
   ::pco/params    []
   ::pco/transform identity}
  (fetch-song env id))

The previous example demonstrates the usage of the most common options in defresolver.

But we don't need to write all of that, for example, instead of manually saying the ::pco/input, we can let the defresolver infer it from the param destructuring, so the following code works the same (::pco/params and ::pco/transform also removed, since they were no-ops in this example):

(pco/defresolver song-by-id [env {:acme.song/keys [id]}]
  {::pco/output [:acme.song/title :acme.song/duration :acme.song/tone]}
  (fetch-song env id))

This makes for a cleaner write, now lets use this format and write a new example resolver:

(pco/defresolver full-name [env {:acme.user/keys [first-name last-name]}]
  {::pco/output [:acme.user/full-name]}
  {:acme.user/full-name (str first-name " " last-name)})

The first thing we see is that we don't use env, so we can omit it.

(pco/defresolver full-name [{:acme.user/keys [first-name last-name]}]
  {::pco/output [:acme.user/full-name]}
  {:acme.user/full-name (str first-name " " last-name)})

Also, when the last expression of the defresolver is a map, it will infer the output shape from it:

(pco/defresolver full-name [{:acme.user/keys [first-name last-name]}]
  {:acme.user/full-name (str first-name " " last-name)})

You can always override the implicit input and output by setting on the configuration map.

Standard options:

::pco/output - description of resolver output, in EQL format ::pco/input - description of resolver input, in EQL format ::pco/params - description of resolver parameters, in EQL format ::pco/transform - a function to transform the resolver configuration before instantiating the resolver

Caching options:

::pco/cache? - true by default, set to false to disable caching for the resolver ::pco/cache-store - a keyword pointing a cache store in the environment ::pco/cache-key - a function of [env input-data] to use as a key when caching this resolver call

Batching options:

::pco/batch? - set true to indicate this resolver does batch processing ::pco/batch-chunk-size - the max size of each batch chunk, when set Pathom will split the batch groups in groups of at max batch-chunk-size items

Note that any other option that you send to the resolver config will be stored in the index and can be read from it at any time.

The returned value is of the type Resolver, you can test your resolver by calling directly:

(full-name {:acme.user/first-name "Ada"
            :acme.user/last-name  "Lovelace"})
=> "Ada Lovelace"

Note that similar to the way we define the resolver, we can also omit env (and even the input) when calling, the resolvers fns always support arity 0, 1 and 2.

Defines a new Pathom resolver.

Resolvers are the central abstraction around Pathom, a resolver is a function
that contains some annotated information and follow a few rules:

1. The resolver input must be a map, so the input information is labelled.
2. A resolver must return a map, so the output information is labelled.
3. A resolver also receives a separated map containing the environment information.

Here are some examples of how you can use the defresolver syntax to define resolvers:

The verbose example:

    (pco/defresolver song-by-id [env {:acme.song/keys [id]}]
      {::pco/input     [:acme.song/id]
       ::pco/output    [:acme.song/title :acme.song/duration :acme.song/tone]
       ::pco/params    []
       ::pco/transform identity}
      (fetch-song env id))

The previous example demonstrates the usage of the most common options in defresolver.

But we don't need to write all of that, for example, instead of manually saying
the ::pco/input, we can let the defresolver infer it from the param destructuring, so
the following code works the same (::pco/params and ::pco/transform also removed, since
they were no-ops in this example):

    (pco/defresolver song-by-id [env {:acme.song/keys [id]}]
      {::pco/output [:acme.song/title :acme.song/duration :acme.song/tone]}
      (fetch-song env id))

This makes for a cleaner write, now lets use this format and write a new example
resolver:

    (pco/defresolver full-name [env {:acme.user/keys [first-name last-name]}]
      {::pco/output [:acme.user/full-name]}
      {:acme.user/full-name (str first-name " " last-name)})

The first thing we see is that we don't use env, so we can omit it.

    (pco/defresolver full-name [{:acme.user/keys [first-name last-name]}]
      {::pco/output [:acme.user/full-name]}
      {:acme.user/full-name (str first-name " " last-name)})

Also, when the last expression of the defresolver is a map, it will infer the output
shape from it:

    (pco/defresolver full-name [{:acme.user/keys [first-name last-name]}]
      {:acme.user/full-name (str first-name " " last-name)})

You can always override the implicit input and output by setting on the configuration
map.

Standard options:

  ::pco/output - description of resolver output, in EQL format
  ::pco/input - description of resolver input, in EQL format
  ::pco/params - description of resolver parameters, in EQL format
  ::pco/transform - a function to transform the resolver configuration before instantiating the resolver

Caching options:

  ::pco/cache? - true by default, set to false to disable caching for the resolver
  ::pco/cache-store - a keyword pointing a cache store in the environment
  ::pco/cache-key - a function of [env input-data] to use as a key when caching this resolver call

Batching options:

  ::pco/batch? - set true to indicate this resolver does batch processing
  ::pco/batch-chunk-size - the max size of each batch chunk, when set Pathom will
                           split the batch groups in groups of at max batch-chunk-size
                           items

Note that any other option that you send to the resolver config will be stored in the
index and can be read from it at any time.

The returned value is of the type Resolver, you can test your resolver by calling
directly:

    (full-name {:acme.user/first-name "Ada"
                :acme.user/last-name  "Lovelace"})
    => "Ada Lovelace"

Note that similar to the way we define the resolver, we can also omit `env` (and even
the input) when calling, the resolvers fns always support arity 0, 1 and 2.
sourceraw docstring

describe-inputclj/s

(describe-input input)
source

describe-input*clj/s

(describe-input* ast path outs* opt-parent?)
source

extract-destructure-map-keys-as-keywordsclj/s

(extract-destructure-map-keys-as-keywords {defaults :or :as m})
source

final-valueclj/s

(final-value x)

Makes a value final. This will add some meta-data to a collection or a map to flag it as final. Data marked as final will make Pathom skip sub-processing it.

Example:

(pco/defresolver complex-done-list []
  {:dont-process (pco/final-value [{:a 1} {:a 2} ...])})

Note that in this case, a query like [{:dont-process [:a :b]}] won't even try to process :b, the vector value will be returned as-is.

Makes a value final. This will add some meta-data to a collection or a map to
flag it as final. Data marked as final will make Pathom skip sub-processing it.

Example:

    (pco/defresolver complex-done-list []
      {:dont-process (pco/final-value [{:a 1} {:a 2} ...])})

Note that in this case, a query like `[{:dont-process [:a :b]}]` won't even try
to process `:b`, the vector value will be returned as-is.
sourceraw docstring

final-value?clj/s

(final-value? x)
source

input-destructure-missingclj/s

(input-destructure-missing {:com.wsscode.pathom3.connect.operation/keys
                              [input inferred-input]})
source

mutationclj/s

(mutation {:com.wsscode.pathom3.connect.operation/keys [transform
                                                        inferred-params]
           :as config})
(mutation op-name config)
(mutation op-name config mutate)

Helper to create a mutation. A mutation must have a name and the mutate function.

You can create a mutation using a map:

(mutation
  {::op-name 'foo
   ::output  [:foo]
   ::mutate  (fn [env params] ...)})

Or with the helper syntax:

(mutation 'foo {} (fn [env params] ...))

Returns an instance of the Mutation type.

Helper to create a mutation. A mutation must have a name and the mutate function.

You can create a mutation using a map:

    (mutation
      {::op-name 'foo
       ::output  [:foo]
       ::mutate  (fn [env params] ...)})

Or with the helper syntax:

    (mutation 'foo {} (fn [env params] ...))

Returns an instance of the Mutation type.
sourceraw docstring

mutation?clj/s

(mutation? x)
source

normalize-arglistclj/s

(normalize-arglist arglist)

Ensures arglist contains two elements.

Ensures arglist contains two elements.
sourceraw docstring

operation-configclj/s

(operation-config operation)
source

operation-typeclj/s

(operation-type operation)
source

operation?clj/s

(operation? x)
source

paramsclj/s

(params env)

Pull parameters from environment. Always returns a map.

Pull parameters from environment. Always returns a map.
sourceraw docstring

params->mutation-optionsclj/s

(params->mutation-options {:keys [arglist options body docstring]})
source

params->resolver-optionsclj/s

(params->resolver-options {:keys [arglist options body docstring]})
source

resolverclj/s

(resolver {:com.wsscode.pathom3.connect.operation/keys [transform
                                                        inferred-input]
           :as config})
(resolver op-name config)
(resolver op-name config resolve)

Helper to create a resolver. A resolver have at least a name, the output definition and the resolve function.

You can create a resolver using a map:

(resolver
  {::op-name 'foo
   ::output  [:foo]
   ::resolve (fn [env input] ...)})

Or with the helper syntax:

(resolver 'foo {::output [:foo]} (fn [env input] ...))

Returns an instance of the Resolver type.

Helper to create a resolver. A resolver have at least a name, the output definition
and the resolve function.

You can create a resolver using a map:

    (resolver
      {::op-name 'foo
       ::output  [:foo]
       ::resolve (fn [env input] ...)})

Or with the helper syntax:

    (resolver 'foo {::output [:foo]} (fn [env input] ...))

Returns an instance of the Resolver type.
sourceraw docstring

resolver?clj/s

(resolver? x)
source

update-configclj/s

(update-config operation f)
(update-config operation f a1)
(update-config operation f a1 a2)
(update-config operation f a1 a2 a3)
(update-config operation f a1 a2 a3 a4)
(update-config operation f a1 a2 a3 a4 a5)
(update-config operation f a1 a2 a3 a4 a5 a6)
(update-config operation f a1 a2 a3 a4 a5 a6 a7)
(update-config operation f a1 a2 a3 a4 a5 a6 a7 a8)
(update-config operation f a1 a2 a3 a4 a5 a6 a7 a8 a9)
(update-config operation f a1 a2 a3 a4 a5 a6 a7 a8 a9 & args)

Returns a new resolver with the modified config. You can use this to change anything in the resolver configuration map. The only thing you can't change from here is the resolver or mutation functions. You can use the wrap-resolve and wrap-mutation helpers to do that.

Returns a new resolver with the modified config. You can use this to change anything
in the resolver configuration map. The only thing you can't change from here is the
resolver or mutation functions. You can use the wrap-resolve and wrap-mutation
helpers to do that.
sourceraw docstring

with-node-paramsclj/s

(with-node-params params)
(with-node-params env params)

Set current node params to params.

Set current node params to params.
sourceraw docstring

wrap-mutateclj/s

(wrap-mutate mutation f)

Return a new mutation with the resolve fn modified. You can use the previous fn or just replace. Here is a noop wrapper example:

(wrap-mutate mutation (fn [mutate] (fn [env params] (mutate env params)))

Return a new mutation with the resolve fn modified. You can use the previous fn or
just replace. Here is a noop wrapper example:

(wrap-mutate mutation
  (fn [mutate]
    (fn [env params]
      (mutate env params)))
sourceraw docstring

wrap-resolveclj/s

(wrap-resolve resolver f)

Return a new resolver with the resolve fn modified. You can use the previous fn or just replace. Here is a noop wrapper example:

(wrap-resolve resolver (fn [resolve] (fn [env input] (resolve env input)))

Return a new resolver with the resolve fn modified. You can use the previous fn or
just replace. Here is a noop wrapper example:

(wrap-resolve resolver
  (fn [resolve]
    (fn [env input]
      (resolve env input)))
sourceraw docstring

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

× close