Skip to content

Commit 50ef82b

Browse files
authored
feat(client-react)!: remove deprecated useQuery legacy query-field aliases (11.0) (#2372)
1 parent b54130c commit 50ef82b

2 files changed

Lines changed: 33 additions & 39 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
"@objectstack/client-react": major
3+
---
4+
5+
Remove the deprecated `useQuery` legacy query-field aliases — use the canonical Spec names (11.0).
6+
7+
`UseQueryOptions` / `useQuery` / `useInfiniteQuery` no longer accept the legacy
8+
aliases `select` / `filters` / `sort` / `top` / `skip`. Use the canonical
9+
protocol names instead:
10+
11+
| removed | use |
12+
|---|---|
13+
| `select` | `fields` |
14+
| `filters` | `where` |
15+
| `sort` | `orderBy` |
16+
| `top` | `limit` |
17+
| `skip` | `offset` |
18+
19+
Behavior is unchanged for callers already on the canonical names.

packages/client-react/src/data-hooks.tsx

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,11 @@ import { PaginatedResult } from '@objectstack/client';
1212
import { useClient } from './context';
1313

1414
/**
15-
* Query options for useQuery hook
15+
* Query options for useQuery hook.
1616
*
17-
* Supports both **canonical** (Spec protocol) and **legacy** field names.
18-
* Canonical names are preferred; legacy names are accepted for backward
19-
* compatibility and will be removed in a future major release.
20-
*
21-
* | Canonical | Legacy (deprecated) |
22-
* |-----------|---------------------|
23-
* | `where` | `filters` |
24-
* | `fields` | `select` |
25-
* | `orderBy` | `sort` |
26-
* | `limit` | `top` |
27-
* | `offset` | `skip` |
17+
* Uses the canonical Spec protocol field names: `where`, `fields`,
18+
* `orderBy`, `limit`, `offset`. (The legacy aliases `filters` / `select` /
19+
* `sort` / `top` / `skip` were removed in 11.0.)
2820
*/
2921
export interface UseQueryOptions<T = any> {
3022
/** Query AST or simplified query options */
@@ -42,17 +34,6 @@ export interface UseQueryOptions<T = any> {
4234
/** Number of records to skip (OFFSET). */
4335
offset?: number;
4436

45-
// ── Legacy field names (deprecated) ────────────────────────────────
46-
/** @deprecated Use `fields` instead. */
47-
select?: string[];
48-
/** @deprecated Use `where` instead. */
49-
filters?: FilterCondition;
50-
/** @deprecated Use `orderBy` instead. */
51-
sort?: string | string[];
52-
/** @deprecated Use `limit` instead. */
53-
top?: number;
54-
/** @deprecated Use `offset` instead. */
55-
skip?: number;
5637

5738
/** Enable/disable automatic query execution */
5839
enabled?: boolean;
@@ -120,20 +101,17 @@ export function useQuery<T = any>(
120101
query,
121102
// Canonical names take precedence over legacy names
122103
where, fields, orderBy, limit, offset,
123-
// Legacy names (deprecated fallbacks)
124-
select, filters, sort, top, skip,
125104
enabled = true,
126105
refetchInterval,
127106
onSuccess,
128107
onError
129108
} = options;
130109

131-
// Resolve canonical vs legacy: canonical wins when both are provided
132-
const resolvedFields = fields ?? select;
133-
const resolvedWhere = where ?? filters;
134-
const resolvedSort = orderBy ?? sort;
135-
const resolvedLimit = limit ?? top;
136-
const resolvedOffset = offset ?? skip;
110+
const resolvedFields = fields;
111+
const resolvedWhere = where;
112+
const resolvedSort = orderBy;
113+
const resolvedLimit = limit;
114+
const resolvedOffset = offset;
137115

138116
const fetchData = useCallback(async (isRefetch = false) => {
139117
if (!enabled) return;
@@ -352,7 +330,7 @@ export function useMutation<TData = any, TVariables = any>(
352330
/**
353331
* Pagination options for usePagination hook
354332
*/
355-
export interface UsePaginationOptions<T = any> extends Omit<UseQueryOptions<T>, 'top' | 'skip' | 'limit' | 'offset'> {
333+
export interface UsePaginationOptions<T = any> extends Omit<UseQueryOptions<T>, 'limit' | 'offset'> {
356334
/** Page size */
357335
pageSize?: number;
358336
/** Initial page (1-based) */
@@ -463,7 +441,7 @@ export function usePagination<T = any>(
463441
/**
464442
* Infinite query options for useInfiniteQuery hook
465443
*/
466-
export interface UseInfiniteQueryOptions<T = any> extends Omit<UseQueryOptions<T>, 'skip' | 'offset'> {
444+
export interface UseInfiniteQueryOptions<T = any> extends Omit<UseQueryOptions<T>, 'offset'> {
467445
/** Page size for each fetch */
468446
pageSize?: number;
469447
/** Get next page parameter */
@@ -533,17 +511,14 @@ export function useInfiniteQuery<T = any>(
533511
query,
534512
// Canonical names take precedence over legacy names
535513
where, fields, orderBy,
536-
// Legacy names (deprecated fallbacks)
537-
select, filters, sort,
538514
enabled = true,
539515
onSuccess,
540516
onError
541517
} = options;
542518

543-
// Resolve canonical vs legacy: canonical wins
544-
const resolvedFields = fields ?? select;
545-
const resolvedWhere = where ?? filters;
546-
const resolvedSort = orderBy ?? sort;
519+
const resolvedFields = fields;
520+
const resolvedWhere = where;
521+
const resolvedSort = orderBy;
547522

548523
const [pages, setPages] = useState<PaginatedResult<T>[]>([]);
549524
const [isLoading, setIsLoading] = useState(true);

0 commit comments

Comments
 (0)