LakeQL
Overview
  • Introduction
Filtering
  • Where Interface
  • Operators
  • Combining Filters
Sorting and Paging
  • Sorting
  • Paging
  • API Reference
GitHub
LakeQL
  1. Query Builder
  2. API Reference

On this page

  1. API Reference
    1. IFieldOptions
    2. ISortInput
    3. IPagingInput
    4. IGenerateQueryProps
    5. IGetFieldQueryProps
    6. IFormatQueryProps
    7. IGetSelectFieldProps
    8. TField
    9. TWhere
    10. FgetFieldQuery
    11. FnormalizeFilter
    12. FnormalizeUserQuery
    13. FgenerateQuery
    14. FformatQuery
    15. FgetSelectFields
    16. EWhereOperator

API Reference

Auto-generated reference for all exported types, interfaces, and functions from @lakeql/query-builder.

Comparison operators available for filtering a single field. Only one operator should be set per FieldOptions object.

String operators compare the field value against the provided string. Boolean operators (is/isNot) check for equality with true/false.

Properties

NameType
eq?string
neq?string
in?string
notIn?string
lt?string
lte?string
gt?string
gte?string
like?string
notLike?string
is?boolean
isNot?boolean

Defines the sort order for a query result.

Type Parameters

ParameterConstraintDefault
TableDefinition——

The table type used to constrain the field to valid column names. See Introduction for details.

Properties

NameType
fieldRequiredSelectExpression< KyselyDatabase<TableDefinition>, keyof KyselyDatabase<TableDefinition> >

Column name to sort by. Constrained to valid column names from the table type.

Kysely API Docs - SelectExpression↗
directionRequired"asc" | "desc"

Sort direction

Controls offset-based pagination.

Properties

NameType
limit?number

Maximum number of rows to return.

Default: 100
offset?number

Number of rows to skip before fetching.

Parameters for generating a Trino-compatible SQL query from GraphQL resolve info.

Type Parameters

ParameterConstraintDefault
TableDefinition——

The table type definition used by Kysely for type-safe column references. See Introduction for details.

Properties

NameType
catalogRequiredstring

The Trino catalog name (e.g. “hive”).

schemaRequiredstring

The Trino schema name (e.g. “sales”).

tableRequiredstring

The table name to query.

selectFieldsRequiredSelectExpression< KyselyDatabase<TableDefinition>, keyof KyselyDatabase<TableDefinition> >[]

The columns to select, derived from GraphQL field selections.

Kysely API Docs - SelectExpression↗
userQueryRequiredWhere

The user-provided filter query (WHERE clause).

paging?PagingInput

Pagination parameters (limit and offset).

sortingRequiredSortInput<TableDefinition>[]

Sort order definitions.

transformFields?Record<string, string>

Maps GraphQL field names to database column names.

dateFields?string[]

Fields that should be wrapped in to_unixtime() for date conversion.

Parameters for building a single field comparison expression.

Type Parameters

ParameterConstraintDefault
TableDefinition——

The table type definition. See Introduction for details.

Properties

NameType
ebRequiredExpressionBuilder<KyselyDatabase<TableDefinition>, "tablename">

The Kysely expression builder for constructing SQL expressions.

Kysely API Docs - ExpressionBuilder↗
fieldNameRequiredstring

The column name to filter on.

operatorRequiredstring

The comparison operator (eq, neq, lt, like, etc.).

valueRequiredunknown

The value to compare against.

Parameters for formatting a compiled SQL query.

Type Parameters

ParameterConstraintDefault
T——

Properties

NameType
queryRequiredCompiledQuery<T>

The compiled Kysely query to format.

Kysely API Docs - CompiledQuery↗

Properties

NameType
graphqlInfoRequiredGraphQLResolveInfo

The GraphQL resolve info from the resolver.

GraphQL Tools - GraphQLResolveInfo↗
withNodes?boolean

When true, looks inside the nodes selection (for Connection types).

Default: false

A single field condition — a record where the key is the field name and the value is a FieldOptions object describing the comparison.

Definition

Record<string, FieldOptions>
See:FieldOptions

A recursive filter structure that can contain AND/OR groups, each holding field conditions or further nested groups.

Definition

Partial<Record<WhereOperator, (Where | Field)[]>>
See:WhereOperatorWhereField

Builds a single field comparison expression for use in WHERE clauses.

Type Parameters

ParameterConstraintDefault
TableDefinition——

Parameters

NameType
getFieldQueryPropsRequiredGetFieldQueryProps<TableDefinition>

Returns

ExpressionWrapper<
  KyselyDatabase<TableDefinition>,
  "tablename",
  SqlBool
>

A Kysely ExpressionWrapper representing the comparison.

Normalizes filter objects by ensuring each field is in its own object within and/or arrays.

Splits multi-field filter objects into separate entries so the query builder can process each field condition independently.

Parameters

NameType
filterRequiredWhere

The filter object to normalize.

Returns

Where

A normalized filter with individual field entries.

Wraps bare field-level filters into an AND-rooted structure.

If the query already has a single and or or key at the root, it is returned as-is. Otherwise, all entries are combined under an and key.

Parameters

NameType
userQueryRequiredWhere

The user-provided filter query.

Returns

Where

A normalized query with a logical operator at the root.

Generates a compiled SQL query with pagination metadata for Trino.

The query uses two CTEs internally:

  • total_count — provides total_records (total matching rows before paging)
  • records — the actual rows based on selectFields , filtering, sorting, and paging

The compiled query is executed by the Trino client which returns the row data.

Type Parameters

ParameterConstraintDefault
TableDefinition——

Parameters

NameType
generateQueryPropsRequiredGenerateQueryProps<TableDefinition>

Returns

CompiledQuery<{ total_records: number; }>

A CompiledQuery ready for execution via the Trino client.

Formats a compiled SQL query for readability.

Applies uppercase keywords, PostgreSQL dialect, and interpolates parameters.

Type Parameters

ParameterConstraintDefault
T——

Parameters

NameType
formatQueryPropsRequiredFormatQueryProps<T>

Returns

string

The formatted SQL string with interpolated parameters.

Extracts selected field names from a GraphQL resolve info object.

Type Parameters

ParameterConstraintDefault
T——

Parameters

NameType
getSelectFieldPropsRequiredGetSelectFieldProps

Returns

SelectExpression<KyselyDatabase<T>, "tablename">[]

An array of field names to use as SELECT columns.

Logical operators for combining filter conditions.

NameType
AND"and"
OR"or"

Next page

Overview