Home > @uniformdev/canvas > queryToProjection

queryToProjection() function

Parses select.* keys from a request query into a ProjectionSpec. Accepts either a URLSearchParams instance (edge handlers) or a flat record produced by the OAS3 validator (origin handlers); both are normalised internally.

Returns undefined when the source contains no select.* keys, so callers can skip allocating localize predicates or walking the tree altogether on the cached / un-projected hot path.

Strict on operator keys: unknown operator shapes throw (e.g. select.fields[foo]). Lenient on value names: unknown field / slot / type names inside CSV lists are kept as-is and silently no-op at projection time if they don't match anything in the tree.

Signature:

Parameters

Parameter

Type

Description

source

URLSearchParams | Record<string, unknown> | null | undefined

Returns:

ProjectionSpec | undefined