Liking cljdoc? Tell your friends :D

com.wsscode.pathom3.connect.operation


?clj/s

(? attr)

Make an attribute optional

Make an attribute optional
raw docstring

as-entry?clj/s

(as-entry? x)

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.
raw 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 ::pcr/cache? - true by default, set to false to disable caching for the resolver

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
  ::pcr/cache? - true by default, set to false to disable caching for the resolver

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

describe-inputclj/s

(describe-input input)

describe-input*clj/s

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

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

(extract-destructure-map-keys-as-keywords m)

final-value?clj/s

(final-value? x)

input-destructure-missingclj/s

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

mutationclj/s

(mutation {:com.wsscode.pathom3.connect.operation/keys [transform] :as 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.
raw docstring

Mutationclj/s


mutation?clj/s

(mutation? x)

normalize-arglistclj/s

(normalize-arglist arglist)

Ensures arglist contains two elements.

Ensures arglist contains two elements.
raw docstring

operation-configclj/s

(operation-config operation)

operation-typeclj/s

(operation-type operation)

operation?clj/s

(operation? x)

paramsclj/s

(params env)

Pull parameters from environment. Always returns a map.

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

params->mutation-optionsclj/s

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

params->resolver-optionsclj/s

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

resolverclj/s

(resolver {:com.wsscode.pathom3.connect.operation/keys [transform op-name
                                                        inferred-input 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.
raw docstring

Resolverclj/s


resolver?clj/s

(resolver? x)

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.
raw 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.
raw 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)))
raw 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)))
raw docstring

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

× close