Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tanstack/query-core

Package Overview
Dependencies
Maintainers
2
Versions
288
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tanstack/query-core - npm Package Compare versions

Comparing version 5.0.0-alpha.63 to 5.0.0-alpha.66

2

build/lib/infiniteQueryBehavior.d.ts
import type { QueryBehavior } from './query';
import type { InfiniteData, InfiniteQueryPageParamsOptions } from './types';
export declare function infiniteQueryBehavior<TQueryFnData, TError, TData>(): QueryBehavior<TQueryFnData, TError, InfiniteData<TData>>;
export declare function infiniteQueryBehavior<TQueryFnData, TError, TData>(pages?: number): QueryBehavior<TQueryFnData, TError, InfiniteData<TData>>;
/**

@@ -5,0 +5,0 @@ * Checks if there is a next page.

import { addToStart, addToEnd } from './utils.js';
function infiniteQueryBehavior() {
function infiniteQueryBehavior(pages) {
return {

@@ -62,9 +62,4 @@ onFetch: context => {

// Fetch first page?
if (!oldPages.length) {
result = await fetchPage(empty, options.defaultPageParam);
}
// fetch next / previous page?
else if (direction) {
if (direction && oldPages.length) {
const previous = direction === 'backward';

@@ -78,11 +73,9 @@ const pageParamFn = previous ? getPreviousPageParam : getNextPageParam;

result = await fetchPage(oldData, param, previous);
}
// Refetch pages
else {
} else {
// Fetch first page
result = await fetchPage(empty, oldPageParams[0]);
result = await fetchPage(empty, oldPageParams[0] ?? options.defaultPageParam);
const remainingPages = pages ?? oldPages.length;
// Fetch remaining pages
for (let i = 1; i < oldPages.length; i++) {
for (let i = 1; i < remainingPages; i++) {
const param = getNextPageParam(options, result);

@@ -89,0 +82,0 @@ result = await fetchPage(result, param);

import { addToStart, addToEnd } from './utils.legacy.js';
function infiniteQueryBehavior() {
function infiniteQueryBehavior(pages) {
return {

@@ -63,9 +63,4 @@ onFetch: context => {

// Fetch first page?
if (!oldPages.length) {
result = await fetchPage(empty, options.defaultPageParam);
}
// fetch next / previous page?
else if (direction) {
if (direction && oldPages.length) {
const previous = direction === 'backward';

@@ -79,11 +74,10 @@ const pageParamFn = previous ? getPreviousPageParam : getNextPageParam;

result = await fetchPage(oldData, param, previous);
}
// Refetch pages
else {
} else {
var _oldPageParams$;
// Fetch first page
result = await fetchPage(empty, oldPageParams[0]);
result = await fetchPage(empty, (_oldPageParams$ = oldPageParams[0]) != null ? _oldPageParams$ : options.defaultPageParam);
const remainingPages = pages != null ? pages : oldPages.length;
// Fetch remaining pages
for (let i = 1; i < oldPages.length; i++) {
for (let i = 1; i < remainingPages; i++) {
const param = getNextPageParam(options, result);

@@ -90,0 +84,0 @@ result = await fetchPage(result, param);

@@ -183,3 +183,3 @@ import { functionalUpdate, noop, hashKey, partialMatchKey, hashQueryKeyByOptions } from './utils.js';

fetchInfiniteQuery(options) {
options.behavior = infiniteQueryBehavior();
options.behavior = infiniteQueryBehavior(options.pages);
return this.fetchQuery(options);

@@ -186,0 +186,0 @@ }

@@ -220,3 +220,3 @@ import { classPrivateFieldLooseBase as _classPrivateFieldLooseBase, classPrivateFieldLooseKey as _classPrivateFieldLooseKey } from './_virtual/_rollupPluginBabelHelpers.legacy.js';

fetchInfiniteQuery(options) {
options.behavior = infiniteQueryBehavior();
options.behavior = infiniteQueryBehavior(options.pages);
return this.fetchQuery(options);

@@ -223,0 +223,0 @@ }

@@ -186,4 +186,10 @@ import type { MutationState } from './mutation';

}
export interface FetchInfiniteQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> extends FetchQueryOptions<TQueryFnData, TError, InfiniteData<TData>, TQueryKey, TPageParam>, DefaultPageParam<TPageParam> {
}
type FetchInfiniteQueryPages<TQueryFnData = unknown, TPageParam = unknown> = {
pages?: never;
getNextPageParam?: never;
} | {
pages: number;
getNextPageParam: GetNextPageParamFunction<TPageParam, TQueryFnData>;
};
export type FetchInfiniteQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = FetchQueryOptions<TQueryFnData, TError, InfiniteData<TData>, TQueryKey, TPageParam> & DefaultPageParam<TPageParam> & FetchInfiniteQueryPages<TQueryFnData, TPageParam>;
export interface ResultOptions {

@@ -190,0 +196,0 @@ throwOnError?: boolean;

{
"name": "@tanstack/query-core",
"version": "5.0.0-alpha.63",
"version": "5.0.0-alpha.66",
"description": "The framework agnostic core that powers TanStack Query",

@@ -5,0 +5,0 @@ "author": "tannerlinsley",

@@ -10,7 +10,5 @@ import type { QueryBehavior } from './query'

export function infiniteQueryBehavior<
TQueryFnData,
TError,
TData,
>(): QueryBehavior<TQueryFnData, TError, InfiniteData<TData>> {
export function infiniteQueryBehavior<TQueryFnData, TError, TData>(
pages?: number,
): QueryBehavior<TQueryFnData, TError, InfiniteData<TData>> {
return {

@@ -88,9 +86,4 @@ onFetch: (context) => {

// Fetch first page?
if (!oldPages.length) {
result = await fetchPage(empty, options.defaultPageParam)
}
// fetch next / previous page?
else if (direction) {
if (direction && oldPages.length) {
const previous = direction === 'backward'

@@ -105,11 +98,13 @@ const pageParamFn = previous ? getPreviousPageParam : getNextPageParam

result = await fetchPage(oldData, param, previous)
}
// Refetch pages
else {
} else {
// Fetch first page
result = await fetchPage(empty, oldPageParams[0])
result = await fetchPage(
empty,
oldPageParams[0] ?? options.defaultPageParam,
)
const remainingPages = pages ?? oldPages.length
// Fetch remaining pages
for (let i = 1; i < oldPages.length; i++) {
for (let i = 1; i < remainingPages; i++) {
const param = getNextPageParam(options, result)

@@ -116,0 +111,0 @@ result = await fetchPage(result, param)

@@ -328,3 +328,5 @@ import type { QueryFilters, Updater, MutationFilters } from './utils'

): Promise<InfiniteData<TData>> {
options.behavior = infiniteQueryBehavior<TQueryFnData, TError, TData>()
options.behavior = infiniteQueryBehavior<TQueryFnData, TError, TData>(
options.pages,
)
return this.fetchQuery(options)

@@ -331,0 +333,0 @@ }

@@ -361,3 +361,10 @@ /* istanbul ignore file */

export interface FetchInfiniteQueryOptions<
type FetchInfiniteQueryPages<TQueryFnData = unknown, TPageParam = unknown> =
| { pages?: never; getNextPageParam?: never }
| {
pages: number
getNextPageParam: GetNextPageParamFunction<TPageParam, TQueryFnData>
}
export type FetchInfiniteQueryOptions<
TQueryFnData = unknown,

@@ -368,10 +375,11 @@ TError = DefaultError,

TPageParam = unknown,
> extends FetchQueryOptions<
TQueryFnData,
TError,
InfiniteData<TData>,
TQueryKey,
TPageParam
>,
DefaultPageParam<TPageParam> {}
> = FetchQueryOptions<
TQueryFnData,
TError,
InfiniteData<TData>,
TQueryKey,
TPageParam
> &
DefaultPageParam<TPageParam> &
FetchInfiniteQueryPages<TQueryFnData, TPageParam>

@@ -378,0 +386,0 @@ export interface ResultOptions {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc