Skip to content

fromPredicate

resolvers
Source Code | Documentation

See also: predicates resolvers/resolveData resolvers/resolveResult resolvers/resolveQuery

Adapts an existing predicate function (like isProvider, isContext) into a resolver condition. The predicate receives the hook context extracted from the resolver options. Only synchronous predicates are supported.

ts
  import {  } from 'feathers-utils/resolvers';

Example

ts
import { resolveResult, omit, fromPredicate } from 'feathers-utils/resolvers'
import { isProvider } from 'feathers-utils/predicates'

resolveResult({
  password: omit(fromPredicate(isProvider('external'))),
})

Type declaration

Show Type Declarations
ts
/**
 * Adapts an existing predicate function (like `isProvider`, `isContext`) into a
 * resolver condition. The predicate receives the hook context extracted from the
 * resolver options. Only synchronous predicates are supported.
 *
 * @example
 * ```ts
 *
 *
 *
 * resolveResult({
 *   password: omit(fromPredicate(isProvider('external'))),
 * })
 * ```
 */
export declare function fromPredicate<H extends HookContext = HookContext>(
  predicate: PredicateFn<H>,
): ResolverCondition<H>
ArgumentTypeDescription
predicatePredicateFn<H>

Usage with Resolver Helpers

fromPredicate bridges existing predicates (like isProvider, isContext, not) into resolver conditions. Predicates receive the hook context, while resolver conditions receive the full ResolverPropertyOptions. This adapter extracts the context and passes it to the predicate.

ts
import { resolveResult, omit, fromPredicate } from "feathers-utils/resolvers";
import { isProvider } from "feathers-utils/predicates";

resolveResult({
  password: omit(fromPredicate(isProvider("external"))),
});

WARNING

fromPredicate only supports synchronous predicates. If the predicate returns a Promise, it will throw an error at runtime.

Released under the MIT License.