/** * Selection helpers for React Query hooks * @generated by @constructive-io/graphql-codegen * DO NOT EDIT - changes will be overwritten */ export interface SelectionConfig { fields: TFields; } export interface ListSelectionConfig extends SelectionConfig { where?: TWhere; orderBy?: TOrderBy[]; first?: number; last?: number; after?: string; before?: string; offset?: number; } function ensureSelectionFields( selection: SelectionConfig | undefined ): asserts selection is SelectionConfig { if (!selection || typeof selection !== 'object' || !('fields' in selection)) { throw new Error( 'Invalid hook params: `selection.fields` is required. Example: { selection: { fields: { id: true } } }' ); } } export function buildSelectionArgs(selection: SelectionConfig): { select: TFields; } { ensureSelectionFields(selection); return { select: selection.fields }; } export function buildListSelectionArgs( selection: ListSelectionConfig ): { select: TFields; where?: TWhere; orderBy?: TOrderBy[]; first?: number; last?: number; after?: string; before?: string; offset?: number; } { ensureSelectionFields(selection); return { select: selection.fields, where: selection.where, orderBy: selection.orderBy, first: selection.first, last: selection.last, after: selection.after, before: selection.before, offset: selection.offset, }; }