Skip to main content
Resolvers transform and compute data properties for Feathers services, enabling virtual properties, data sanitization, and context-aware transformations.

resolve

Creates a resolver instance that resolves properties based on property resolver functions.

Signatures

Parameters

PropertyResolverMap<T, C>
required
Object mapping property names to resolver functions
ResolverOptions<T, C>
Optional configuration object
ResolverOptions:
Schema<T>
Schema for validation. Can be used with validate option
ResolverConverter<T, C>
Function to transform data before property resolution
'before' | 'after' | false
Deprecated. When to validate: before or after resolution. Use validateData hook instead

Returns

Returns a Resolver<T, C> instance.

Resolver

The resolver class that handles property resolution.

resolve

Resolves all properties for the given data:
D
required
Data object to resolve
C
required
Context object (typically HookContext)
Partial<ResolverStatus<T, C>>
Optional resolver status for nested resolution
Returns: Promise<T> - Resolved data object

resolveProperty

Resolves a single property:
keyof T
required
Property name to resolve
D
required
Data object containing the property
C
required
Context object
Partial<ResolverStatus<T, C>>
Optional resolver status
Returns: Promise<T[K]> - Resolved property value

convert

Converts data using the configured converter:
D
required
Data to convert
C
required
Context object
Partial<ResolverStatus<T, C>>
Optional resolver status
Returns: Promise<T | undefined> - Converted data

Property Resolvers

Property resolver functions transform individual properties.

PropertyResolver

Type signature for property resolvers:
V | undefined
Current value of the property
T
The entire data object being resolved
C
Context object (e.g., HookContext)
ResolverStatus<T, C>
Current resolution status with path and stack information
Returns: Resolved value or undefined to remove the property

Example

virtual

Creates a resolver for a computed property that has no initial value.

Parameters

VirtualResolver<T, V, C>
required
Function to compute the virtual property
VirtualResolver signature:

Returns

Returns a PropertyResolver<T, V, C> marked as virtual.

Types

ResolverStatus

Tracking object passed through resolution:

ResolverConverter

Function to convert data before property resolution:

PropertyResolverMap

Object mapping properties to their resolvers:

Examples

Basic Property Resolution

Virtual Properties

Context-Aware Resolution

With Data Converter

Selective Property Resolution

Nested Resolution