Liking cljdoc? Tell your friends :D

us.whitford.fulcro.rad.database-adapters.datalevin.pathom-plugin

Pathom environment wiring for the Datalevin database adapter.

This namespace has NO hard dependency on any Pathom version:

  • wrap-env is a plain (fn [env] env') augmentor. It is the idiomatic Pathom 3 integration point — compose it into the env-middleware you pass to RAD's com.fulcrologic.rad.pathom3/new-processor (alongside attr/wrap-env and form/wrap-env).
  • pathom-plugin wraps that same augmentation in a Pathom 2 ::p/wrap-parser plugin map (a plain namespaced keyword literal — no pathom require needed), for use with com.fulcrologic.rad.pathom/new-parser.
Pathom environment wiring for the Datalevin database adapter.

This namespace has NO hard dependency on any Pathom version:

- `wrap-env` is a plain `(fn [env] env')` augmentor. It is the idiomatic
  **Pathom 3** integration point — compose it into the `env-middleware` you
  pass to RAD's `com.fulcrologic.rad.pathom3/new-processor` (alongside
  `attr/wrap-env` and `form/wrap-env`).
- `pathom-plugin` wraps that same augmentation in a **Pathom 2**
  `::p/wrap-parser` plugin map (a plain namespaced keyword literal — no
  pathom require needed), for use with `com.fulcrologic.rad.pathom/new-parser`.
raw docstring

pathom-pluginclj

(pathom-plugin database-mapper)

Create a Pathom 2 plugin that adds Datalevin database support.

The plugin augments the parsing env for each request so that the current database value is available to all resolvers. Database snapshots are taken once per request (parser call) and reused for consistency.

Arguments:

  • database-mapper: a function (fn [pathom-env] {schema-name connection}) for a given request.

The resulting pathom-env available to all resolvers will then have:

  • dlo/connections: the result of database-mapper
  • dlo/databases: a map from schema name to current database values

Returns a Pathom 2 plugin map keyed by :com.wsscode.pathom.core/wrap-parser (the keyword is written as a literal, so this namespace does not depend on pathom being present).

For Pathom 3, do not use this plugin; compose wrap-env into your processor's env-middleware instead.

Create a **Pathom 2** plugin that adds Datalevin database support.

The plugin augments the parsing env for each request so that the current
database value is available to all resolvers. Database snapshots are taken
once per request (parser call) and reused for consistency.

Arguments:
- database-mapper: a function `(fn [pathom-env] {schema-name connection})`
  for a given request.

The resulting pathom-env available to all resolvers will then have:
- `dlo/connections`: the result of database-mapper
- `dlo/databases`:   a map from schema name to current database values

Returns a Pathom 2 plugin map keyed by
`:com.wsscode.pathom.core/wrap-parser` (the keyword is written as a literal,
so this namespace does not depend on pathom being present).

For **Pathom 3**, do not use this plugin; compose `wrap-env` into your
processor's `env-middleware` instead.
sourceraw docstring

refresh-db-snapshot!clj

(refresh-db-snapshot! env schema db-after)

Publish db-after into the atom-backed dlo/databases snapshot for schema in env, so resolvers running later in the same Pathom request read their own writes while keeping a stable, request-scoped view.

Called by the save/delete middleware with the transaction report's :db-after. No-op when db-after is nil or when env has no atom snapshot for schema (e.g. a save-only env with no read wiring). Returns nil.

Publish `db-after` into the atom-backed `dlo/databases` snapshot for `schema`
in `env`, so resolvers running later in the same Pathom request read their own
writes while keeping a stable, request-scoped view.

Called by the save/delete middleware with the transaction report's
`:db-after`. No-op when `db-after` is nil or when `env` has no atom snapshot
for `schema` (e.g. a save-only env with no read wiring). Returns nil.
sourceraw docstring

wrap-envclj

(wrap-env database-mapper)
(wrap-env base-wrapper database-mapper)

Wrap the pathom environment with database connections and snapshots.

This is the Pathom 3 integration point: the returned (fn [env] env') can be composed into the env-middleware given to RAD's Pathom 3 processor.

Arguments:

  • base-wrapper: optional function to further wrap the env
  • database-mapper: function that takes env and returns map of schema -> connection

Returns a function that wraps the environment, adding:

  • dlo/connections: the result of database-mapper (schema -> connection)
  • dlo/databases: a map from schema name to an atom holding the current Datalevin database value. Storing an atom (rather than a bare db) lets the save/delete middleware publish the post-transaction :db-after into the same request env, so resolvers running later in the request read their own writes. See refresh-db-snapshot!.
Wrap the pathom environment with database connections and snapshots.

This is the **Pathom 3** integration point: the returned `(fn [env] env')`
can be composed into the `env-middleware` given to RAD's Pathom 3 processor.

Arguments:
- base-wrapper: optional function to further wrap the env
- database-mapper: function that takes env and returns map of schema -> connection

Returns a function that wraps the environment, adding:
- `dlo/connections`: the result of database-mapper (schema -> connection)
- `dlo/databases`:   a map from schema name to an **atom** holding the current
  Datalevin database value. Storing an atom (rather than a bare db) lets the
  save/delete middleware publish the post-transaction `:db-after` into the
  same request env, so resolvers running later in the request read their own
  writes. See `refresh-db-snapshot!`.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close