Resolver generation for Datalevin database adapter.
Resolver generation for Datalevin database adapter.
Maximum number of entities to fetch in a single batch query.
Maximum number of entities to fetch in a single batch query.
(all-ids-resolver all-attributes
{:com.fulcrologic.rad.attributes/keys [qualified-key]
:keys [:com.fulcrologic.rad.attributes/schema]
:as id-attribute})Generates a resolver that returns all IDs for a given entity type.
Arguments:
Returns a resolver that outputs all entity IDs for queries like :account/all. Use a join query to get additional fields: [{:account/all [:account/id :account/name]}]
For native-id attributes, finds entities by querying for any non-identity attribute from the same entity type (e.g., for :person/id, looks for entities with :person/name).
Example:
Generates a resolver that returns all IDs for a given entity type.
Arguments:
- all-attributes: All attributes in the system
- id-attribute: The identity attribute (e.g., :account/id)
Returns a resolver that outputs all entity IDs for queries like :account/all.
Use a join query to get additional fields: [{:account/all [:account/id :account/name]}]
For native-id attributes, finds entities by querying for any non-identity attribute
from the same entity type (e.g., for :person/id, looks for entities with :person/name).
Example:
- For :account/id, creates a resolver for :account/all
- Query [:account/all] returns [{:account/id uuid-1} {:account/id uuid-2} ...](datalevin-result->pathom-result key->attribute pathom-query result)Convert a Datalevin result containing :db/id into a Pathom result containing the proper id keyword that was used in the original query.
Convert a Datalevin result containing :db/id into a Pathom result containing the proper id keyword that was used in the original query.
(generate-resolvers attributes schema)Generate all of the resolvers that make sense for the given database config. This should be passed to your Pathom parser to register resolvers for each of your schemas.
Returns Pathom-2-shape resolver maps (plain data keyed by
:com.wsscode.pathom.connect/{sym,input,output,batch?,resolve}). This makes
the adapter Pathom-version-agnostic and free of any hard pathom dependency:
com.fulcrologic.rad.pathom3/new-processor already runs
convert-resolvers on whatever you pass it, so these maps auto-convert. If
you build a Pathom 3 index yourself, use generate-resolvers-pathom3 (or
RAD's convert-resolvers) to get native Pathom 3 resolver records.Generates four types of resolvers:
Generate all of the resolvers that make sense for the given database config. This should be passed
to your Pathom parser to register resolvers for each of your schemas.
Returns **Pathom-2-shape resolver maps** (plain data keyed by
`:com.wsscode.pathom.connect/{sym,input,output,batch?,resolve}`). This makes
the adapter Pathom-version-agnostic and free of any hard pathom dependency:
- **Pathom 2**: register the returned maps directly with your parser.
- **Pathom 3**: RAD's `com.fulcrologic.rad.pathom3/new-processor` already runs
`convert-resolvers` on whatever you pass it, so these maps auto-convert. If
you build a Pathom 3 index yourself, use `generate-resolvers-pathom3` (or
RAD's `convert-resolvers`) to get native Pathom 3 resolver records.
Generates four types of resolvers:
1. ID resolvers: resolve entity data by ID (e.g., :account/id -> account data)
2. All-IDs resolvers: resolve all entity IDs (e.g., :all-accounts -> [{:account/id ...} ...])
3. Search resolvers (only for entity types with ::dlo/fulltext? attributes):
parameterized full-text search returning relevance-ordered idents
(e.g., :account/search — see search-resolver)
4. Similar resolvers (only for entity types with :vec attributes):
parameterized vector similarity search returning nearest-neighbor idents
(e.g., :account/similar — see similar-resolver)(generate-resolvers-pathom3 attributes schema)Like generate-resolvers, but returns native Pathom 3 resolver records
instead of Pathom-2-shape maps.
Convenience for callers that build a Pathom 3 index directly (rather than via
RAD's new-processor, which already converts). The conversion is delegated to
RAD's own com.fulcrologic.rad.pathom3/convert-resolvers, resolved lazily at
call time via requiring-resolve so that pathom3 remains an optional,
runtime-only dependency — this namespace never requires it at load time.
Throws if pathom3 (and thus com.fulcrologic.rad.pathom3) is not on the
classpath.
Like `generate-resolvers`, but returns native **Pathom 3** resolver records instead of Pathom-2-shape maps. Convenience for callers that build a Pathom 3 index directly (rather than via RAD's `new-processor`, which already converts). The conversion is delegated to RAD's own `com.fulcrologic.rad.pathom3/convert-resolvers`, resolved lazily at call time via `requiring-resolve` so that **pathom3 remains an optional, runtime-only dependency** — this namespace never requires it at load time. Throws if pathom3 (and thus `com.fulcrologic.rad.pathom3`) is not on the classpath.
(get-by-ids db id-attr ids pull-pattern)(get-by-ids db id-attr ids pull-pattern enum-keys)(get-by-ids db id-attr ids pull-pattern enum-keys native-id?)Fetch multiple entities by their identity attribute values.
Arguments:
Returns a map of id -> entity data.
Throws if ids count exceeds max-batch-size. Logs warning for large batches (> 100 ids).
Fetch multiple entities by their identity attribute values. Arguments: - db: database value - id-attr: the identity attribute keyword - ids: collection of id values (max *max-batch-size*). For native IDs, these are entity IDs directly. - pull-pattern: EQL pull pattern - enum-keys: (optional) set of attribute keywords that are enums, to be converted to :db/ident - native-id?: (optional) if true, ids are raw entity IDs (not lookup refs) Returns a map of id -> entity data. Throws if ids count exceeds *max-batch-size*. Logs warning for large batches (> 100 ids).
(id-resolver all-attributes
{:com.fulcrologic.rad.attributes/keys [qualified-key]
:keys [:com.fulcrologic.rad.attributes/schema]
:as id-attribute}
output-attributes)Generates a resolver from id-attribute to the output-attributes.
Handles:
Generates a resolver from `id-attribute` to the `output-attributes`. Handles: - Native ID attributes (using :db/id directly) - Enum attribute conversion (db refs -> keywords) - Optional wrap-resolve for custom pre/post processing
(native-id? attribute)Returns true if the given attribute uses native :db/id.
Returns true if the given attribute uses native :db/id.
(pathom-query->datalevin-query all-attributes pathom-query)Convert a Pathom EQL query to a Datalevin pull pattern.
Replaces any native-id identity attribute keys with :db/id in the pull pattern, since native-id attributes use Datalevin's built-in entity ID.
Convert a Pathom EQL query to a Datalevin pull pattern. Replaces any native-id identity attribute keys with :db/id in the pull pattern, since native-id attributes use Datalevin's built-in entity ID.
(ref-entity->ident db {:db/keys [ident id] :as ent})Convert an entity reference to its :db/ident keyword value.
If the entity has a :db/ident, returns that keyword. Otherwise returns the entity unchanged (not an enum).
Convert an entity reference to its :db/ident keyword value. If the entity has a :db/ident, returns that keyword. Otherwise returns the entity unchanged (not an enum).
(replace-ref-types db enum-keys result)Walk through query results and replace enum entity references with their :db/ident keywords.
Arguments:
Returns the result with enum entity maps replaced by their :db/ident keyword values.
Walk through query results and replace enum entity references with their :db/ident keywords. Arguments: - db: database value - enum-keys: set of attribute keywords that are enums - result: the pull result to transform Returns the result with enum entity maps replaced by their :db/ident keyword values.
(search-resolver all-attributes
{:com.fulcrologic.rad.attributes/keys [qualified-key]
:keys [:com.fulcrologic.rad.attributes/schema]
:as id-attribute})Generates a full-text search resolver for an entity type, or nil when the
entity has no ::dlo/fulltext? attributes.
Output: {:<ns>/search [{id-attr ...} ...]} — idents in RELEVANCE order
(descending full-text score). Fields are filled by the existing batched
id-resolver via a join query, e.g.
[{(:account/search {:query "fox"}) [:account/id :account/name]}].
Params — read from (:query-params env), which both RAD parsers populate
from the EQL join params ({:params {:query ...}} on a load):
:query (required) — the search query: a string, a boolean expression
vector like [:and "x" [:not "y"]], or {:phrase "..."} (phrase
search requires the attribute to be declared
::dlo/fulltext? {:index-position? true}).:top — cap on engine results (Datalevin default 10).:limit / :offset — pagination within the result window.
A missing or blank :query resolves to an empty list (no throw), so a
report with an empty search control renders empty.Relevance ordering is obtained via {:display :refs+scores} plus an
explicit descending sort — Datalog's set semantics do NOT preserve the
engine's rank order (runtime-proven; see the full-text design doc).
Native-id aware: for ::dlo/native-id? entities the matched eid IS the id;
otherwise the identity attribute's value is pulled per matched eid.
Generates a full-text search resolver for an entity type, or nil when the
entity has no `::dlo/fulltext?` attributes.
Output: `{:<ns>/search [{id-attr ...} ...]}` — idents in RELEVANCE order
(descending full-text score). Fields are filled by the existing batched
id-resolver via a join query, e.g.
`[{(:account/search {:query "fox"}) [:account/id :account/name]}]`.
Params — read from `(:query-params env)`, which both RAD parsers populate
from the EQL join params (`{:params {:query ...}}` on a load):
- `:query` (required) — the search query: a string, a boolean expression
vector like `[:and "x" [:not "y"]]`, or `{:phrase "..."}` (phrase
search requires the attribute to be declared
`::dlo/fulltext? {:index-position? true}`).
- `:top` — cap on engine results (Datalevin default 10).
- `:limit` / `:offset` — pagination within the result window.
A missing or blank `:query` resolves to an empty list (no throw), so a
report with an empty search control renders empty.
Relevance ordering is obtained via `{:display :refs+scores}` plus an
explicit descending sort — Datalog's set semantics do NOT preserve the
engine's rank order (runtime-proven; see the full-text design doc).
Native-id aware: for `::dlo/native-id?` entities the matched eid IS the id;
otherwise the identity attribute's value is pulled per matched eid.(similar-resolver all-attributes
{:com.fulcrologic.rad.attributes/keys [qualified-key]
:keys [:com.fulcrologic.rad.attributes/schema]
:as id-attribute})Generates a vector similarity (semantic) search resolver for an entity type,
or nil when the entity has no :vec attributes.
Output: {:<ns>/similar [{id-attr ...} ...]} — idents in SIMILARITY order
(ascending vector distance; nearest first). Fields are filled by the
existing batched id-resolver via a join query, e.g.
[{(:account/similar {:vector [...]}) [:account/id :account/name]}].
Params — read from (:query-params env), which both RAD parsers populate
from the EQL join params ({:params {:vector ...}} on a load):
:vector (required) — the query embedding (a sequence of numbers whose
dimension matches the attribute's :db.vec/dimensions).:attribute — optional qualified keyword of a specific :vec attribute
to search (e.g. :account/embedding). Defaults to all of the entity's
:vec attribute domains (they must share dimensions to be searched
together).:top — cap on results (Datalevin default 10).
A missing :vector resolves to an empty list (no throw).Similarity ordering is obtained via {:display :refs+dists} plus an
explicit ascending sort — Datalog's set semantics do NOT preserve the
engine's rank order (same finding as full-text; runtime-proven).
Native-id aware: for ::dlo/native-id? entities the matched eid IS the id;
otherwise the identity attribute's value is pulled per matched eid.
Pairs with the full-text :<ns>/search resolver for hybrid keyword +
semantic search over the same entities.
Generates a vector similarity (semantic) search resolver for an entity type,
or nil when the entity has no `:vec` attributes.
Output: `{:<ns>/similar [{id-attr ...} ...]}` — idents in SIMILARITY order
(ascending vector distance; nearest first). Fields are filled by the
existing batched id-resolver via a join query, e.g.
`[{(:account/similar {:vector [...]}) [:account/id :account/name]}]`.
Params — read from `(:query-params env)`, which both RAD parsers populate
from the EQL join params (`{:params {:vector ...}}` on a load):
- `:vector` (required) — the query embedding (a sequence of numbers whose
dimension matches the attribute's `:db.vec/dimensions`).
- `:attribute` — optional qualified keyword of a specific `:vec` attribute
to search (e.g. `:account/embedding`). Defaults to all of the entity's
`:vec` attribute domains (they must share dimensions to be searched
together).
- `:top` — cap on results (Datalevin default 10).
A missing `:vector` resolves to an empty list (no throw).
Similarity ordering is obtained via `{:display :refs+dists}` plus an
explicit ascending sort — Datalog's set semantics do NOT preserve the
engine's rank order (same finding as full-text; runtime-proven).
Native-id aware: for `::dlo/native-id?` entities the matched eid IS the id;
otherwise the identity attribute's value is pulled per matched eid.
Pairs with the full-text `:<ns>/search` resolver for hybrid keyword +
semantic search over the same entities.cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |