Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/huge-ties-turn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"mobx-tanstack-query": major
---

### Breaking changes

- Removed deprecated `Destroyable.dispose()` — use `destroy()` or `Symbol.dispose` / `using` where supported.
- Removed `Mobx*` type aliases and `MobxQuery` / `MobxMutation` / `MobxInfiniteQuery` class aliases; import the canonical names (`Query`, `Mutation`, `InfiniteQuery`, `QueryOptions`, `DefaultOptions`, etc.).
- Removed deprecated query client aliases: `IQueryClient`, `QueryClientInterface`, `MobxDefaultOptions`, `MobxQueryClientHooks`, `MobxQueryClientConfig`.
- Removed `resetOnDispose` from query features and mutation options / defaults — use `resetOnDestroy` only.
6 changes: 1 addition & 5 deletions src/base-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,7 @@ export abstract class BaseQuery<
config.cumulativeQueryHash ?? qf?.cumulativeQueryHash,
enableOnDemand: config.enableOnDemand ?? qf?.enableOnDemand,
lazy: config.lazy ?? qf?.lazy,
resetOnDestroy:
config.resetOnDestroy ??
config.resetOnDispose ??
qf?.resetOnDestroy ??
qf?.resetOnDispose,
resetOnDestroy: config.resetOnDestroy ?? qf?.resetOnDestroy,
removeOnDestroy: config.removeOnDestroy ?? qf?.removeOnDestroy,
transformError: config.transformError ?? qf?.transformError,
dynamicOptionsUpdateDelay:
Expand Down
22 changes: 11 additions & 11 deletions src/infinite-query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class InfiniteQueryMock<
queryFn: null as unknown as ReturnType<typeof vi.fn>,
setData: vi.fn(),
update: vi.fn(),
dispose: vi.fn(),
destroy: vi.fn(),
refetch: vi.fn(),
invalidate: vi.fn(),
onDone: vi.fn(),
Expand Down Expand Up @@ -107,9 +107,9 @@ class InfiniteQueryMock<
return result;
}

dispose(): void {
const result = super.dispose();
this.spies.dispose.mockReturnValue(result)();
destroy(): void {
const result = super.destroy();
this.spies.destroy.mockReturnValue(result)();
}
}

Expand All @@ -130,7 +130,7 @@ describe('InfiniteQuery', () => {
queryKey: ['test'],
});

query.dispose();
query.destroy();
});

it('should call queryFn with initialPageParam', async () => {
Expand All @@ -150,7 +150,7 @@ describe('InfiniteQuery', () => {
queryKey: ['test'],
});

query.dispose();
query.destroy();
});

it('should use initialPageParam from dynamic options without top-level initialPageParam', async () => {
Expand Down Expand Up @@ -295,7 +295,7 @@ describe('InfiniteQuery', () => {
queryKey: ['test'],
});

query.dispose();
query.destroy();
});

it('should call queryFn with getNextPageParam returning null', async () => {
Expand Down Expand Up @@ -352,7 +352,7 @@ describe('InfiniteQuery', () => {
status: 'success',
});

query.dispose();
query.destroy();
});

it('should call queryFn after fetchNextPage call', async () => {
Expand Down Expand Up @@ -438,7 +438,7 @@ describe('InfiniteQuery', () => {
status: 'success',
});

query.dispose();
query.destroy();
});

it('should call queryFn after fetchNextPage call (x3 times)', async () => {
Expand Down Expand Up @@ -536,7 +536,7 @@ describe('InfiniteQuery', () => {
status: 'success',
});

query.dispose();
query.destroy();
});

describe('"enabled" reactive parameter', () => {
Expand All @@ -556,7 +556,7 @@ describe('InfiniteQuery', () => {
expect(query.spies.queryFn).toBeCalledTimes(1);
expect(query.spies.queryFn).nthReturnedWith(1, 100);

query.dispose();
query.destroy();
});
});

Expand Down
16 changes: 0 additions & 16 deletions src/inifinite-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,19 +381,3 @@ export class InfiniteQuery<
this.hooks?.onInfiniteQueryDestroy?.(this);
}
}

/**
* @deprecated ⚠️ use `InfiniteQuery`. This export will be removed in next major release
*/
export class MobxInfiniteQuery<
TData,
TError = DefaultError,
TQueryKey extends QueryKey = any,
TPageParam = unknown,
> extends InfiniteQuery<
TData,
TError,
TPageParam,
InfiniteData<TData, TPageParam>,
TQueryKey
> {}
84 changes: 0 additions & 84 deletions src/inifinite-query.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,9 @@ export type InfiniteQueryDoneListener<TData = unknown> = (

export interface InfiniteQueryInvalidateParams extends QueryInvalidateParams {}

/**
* @deprecated ⚠️ use `InfiniteQueryInvalidateParams`. This type will be removed in next major release
*/
export type MobxInfiniteQueryInvalidateParams = InfiniteQueryInvalidateParams;

export interface InfiniteQueryResetParams extends QueryResetParams {}
export interface InfiniteQueryRemoveParams extends QueryRemoveParams {}

/**
* @deprecated ⚠️ use `InfiniteQueryResetParams`. This type will be removed in next major release
*/
export type MobxInfiniteQueryResetParams = InfiniteQueryResetParams;

type InfiniteQueryOptionTypeFixes<
TQueryFnData = unknown,
TError = DefaultError,
Expand Down Expand Up @@ -86,22 +76,6 @@ export interface InfiniteQueryDynamicOptions<
enabled?: boolean;
}

/**
* @deprecated ⚠️ use `InfiniteQueryDynamicOptions`. This type will be removed in next major release
*/
export type MobxInfiniteQueryDynamicOptions<
TData,
TError = DefaultError,
TQueryKey extends QueryKey = QueryKey,
TPageParam = unknown,
> = InfiniteQueryDynamicOptions<
TData,
TError,
TPageParam,
InfiniteData<TData, TPageParam>,
TQueryKey
>;

export interface InfiniteQueryOptions<
TQueryFnData = unknown,
TError = DefaultError,
Expand All @@ -126,22 +100,6 @@ export interface InfiniteQueryOptions<
TQueryKey
> {}

/**
* @deprecated ⚠️ use `InfiniteQueryOptions`. This type will be removed in next major release
*/
export type MobxInfiniteQueryOptions<
TData,
TError = DefaultError,
TQueryKey extends QueryKey = QueryKey,
TPageParam = unknown,
> = InfiniteQueryOptions<
TData,
TError,
TPageParam,
InfiniteData<TData, TPageParam>,
TQueryKey
>;

export interface InfiniteQueryUpdateOptions<
TQueryFnData = unknown,
TError = DefaultError,
Expand Down Expand Up @@ -183,22 +141,6 @@ export interface InfiniteQueryStartParams<
>,
Pick<RefetchOptions, 'cancelRefetch'> {}

/**
* @deprecated ⚠️ use `InfiniteQueryUpdateOptions`. This type will be removed in next major release
*/
export type MobxInfiniteQueryUpdateOptions<
TData,
TError = DefaultError,
TQueryKey extends QueryKey = QueryKey,
TPageParam = unknown,
> = InfiniteQueryUpdateOptions<
TData,
TError,
TPageParam,
InfiniteData<TData, TPageParam>,
TQueryKey
>;

export type InfiniteQueryConfigFromFn<
TFn extends (...args: any[]) => any,
TError = DefaultError,
Expand Down Expand Up @@ -240,16 +182,6 @@ export type InfiniteQueryUpdateOptionsAllVariants<
TQueryKey
>;

/**
* @deprecated ⚠️ use `InfiniteQueryConfigFromFn`. This type will be removed in next major release
*/
export type MobxInfiniteQueryConfigFromFn<
TFn extends (...args: any[]) => any,
TError = DefaultError,
TQueryKey extends QueryKey = QueryKey,
TPageParam = unknown,
> = InfiniteQueryConfigFromFn<TFn, TError, TQueryKey, TPageParam>;

export interface InfiniteQueryConfig<
TQueryFnData = unknown,
TError = DefaultError,
Expand Down Expand Up @@ -332,22 +264,6 @@ export interface InfiniteQueryFlattenConfig<
queryKey?: TQueryKey;
}

/**
* @deprecated ⚠️ use `InfiniteQueryConfig`. This type will be removed in next major release
*/
export type MobxInfiniteQueryConfig<
TData,
TError = DefaultError,
TQueryKey extends QueryKey = QueryKey,
TPageParam = unknown,
> = InfiniteQueryConfig<
TData,
TError,
TPageParam,
InfiniteData<TData, TPageParam>,
TQueryKey
>;

export type InferInfiniteQuery<
T extends
| InfiniteQueryConfig<any, any, any, any, any>
Expand Down
8 changes: 4 additions & 4 deletions src/mutation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MutationMock<
> extends Mutation<TData, TVariables, TError, TContext> {
spies = {
mutationFn: null as unknown as ReturnType<typeof vi.fn>,
dispose: vi.fn(),
destroy: vi.fn(),
reset: vi.fn(),
onDone: vi.fn(),
onError: vi.fn(),
Expand Down Expand Up @@ -54,9 +54,9 @@ class MutationMock<
this.spies.reset.mockReturnValue(result)();
}

dispose(): void {
const result = super.dispose();
this.spies.dispose.mockReturnValue(result)();
destroy(): void {
const result = super.destroy();
this.spies.destroy.mockReturnValue(result)();
}
}

Expand Down
15 changes: 1 addition & 14 deletions src/mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,7 @@ export class Mutation<
config.invalidateByKey ?? qc.mutationFeatures?.invalidateByKey,
lazy: config.lazy ?? qc.mutationFeatures?.lazy,
resetOnDestroy:
config.resetOnDestroy ??
config.resetOnDispose ??
qc.mutationFeatures?.resetOnDestroy ??
qc.mutationFeatures?.resetOnDispose,
config.resetOnDestroy ?? qc.mutationFeatures?.resetOnDestroy,
transformError:
config.transformError ?? qc.mutationFeatures?.transformError,
};
Expand Down Expand Up @@ -393,13 +390,3 @@ export class Mutation<
this.hooks?.onMutationDestroy?.(this);
}
}

/**
* @deprecated ⚠️ use `Mutation`. This export will be removed in next major release
*/
export class MobxMutation<
TData = unknown,
TVariables = void,
TError = DefaultError,
TOnMutateResult = unknown,
> extends Mutation<TData, TVariables, TError, TOnMutateResult> {}
44 changes: 0 additions & 44 deletions src/mutation.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ export interface MutationFeatures {
invalidateByKey?:
| boolean
| Omit<InvalidateQueryFilters, 'queryKey' | 'predicate'>;
/**
* Reset mutation when dispose is called
*
* @deprecated Please use 'resetOnDestroy'
*/
resetOnDispose?: boolean;

/**
* Reset mutation when destroy or abort signal is called
Expand All @@ -39,37 +33,18 @@ export interface MutationFeatures {
transformError?: (error: any) => any;
}

/**
* @deprecated ⚠️ use `MutationFeatures`. This type will be removed in next major release
*/
export type MobxMutationFeatures = MutationFeatures;

export interface MutationInvalidateQueriesOptions
extends Omit<InvalidateQueryFilters, 'queryKey'> {
queryKey?: InvalidateQueryFilters['queryKey'];
queryKeys?: InvalidateQueryFilters['queryKey'][];
allQueryKeys?: true;
}

/**
* @deprecated ⚠️ use `MutationInvalidateQueriesOptions`. This type will be removed in next major release
*/
export type MobxMutationInvalidateQueriesOptions =
MutationInvalidateQueriesOptions;

export type MutationFn<TData = unknown, TVariables = unknown> = (
variables: TVariables,
context: MutationFunctionContext,
) => Promise<TData>;

/**
* @deprecated ⚠️ use `MutationFn`. This type will be removed in next major release
*/
export type MobxMutationFunction<
TData = unknown,
TVariables = unknown,
> = MutationFn<TData, TVariables>;

export type MutationSettledListener<
TData = unknown,
TError = DefaultError,
Expand Down Expand Up @@ -119,16 +94,6 @@ export interface MutationFunctionContext extends MutationFunctionContextCore {
signal: AbortSignal;
}

/**
* @deprecated ⚠️ use `MutationConfig`. This type will be removed in next major release
*/
export type MobxMutationConfig<
TData = unknown,
TVariables = void,
TError = DefaultError,
TContext = unknown,
> = MutationConfig<TData, TVariables, TError, TContext>;

export type MutationConfigFromFn<
T extends (...args: any[]) => any,
TError = DefaultError,
Expand All @@ -140,15 +105,6 @@ export type MutationConfigFromFn<
TContext
>;

/**
* @deprecated ⚠️ use `MutationConfigFromFn`. This type will be removed in next major release
*/
export type MobxMutationConfigFromFn<
T extends (...args: any[]) => any,
TError = DefaultError,
TContext = unknown,
> = MutationConfigFromFn<T, TError, TContext>;

export type InferMutation<
T extends MutationConfig | Mutation,
TInferValue extends
Expand Down
Loading
Loading