Skip to content

Commit

Permalink
docs(skipContext): add the JSDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
ArturAbdullin committed Mar 10, 2025
1 parent 093dd36 commit 1f28702
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/core/utils/skipContext.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
import type {AnyFunction} from '../types/utils';

/**
* @param fetch fetch function
* @returns fetch function with the ignored query data source context and the query function context.
*
* @description
* The function is intended to be used with the `fetch` parameter of the query data source config.
* It is used to ignore the query data context and the query function context parameters.
*
* NOTE
* When passed directly to the `fetch` parameter, typescript fails to infer the types of the `DataSource` fields.
* It is better to define a constant first.
* @example
* function someFetchFunction(request: TRequest) {...}
*
* const fetchData = skipContext(someFetchFunction);
*
* const dataSource = makePlainQueryDataSource({
* ...
* fetch: fetchData,
* ...
* })
*/
export const skipContext = <TFunc extends AnyFunction>(fetch: TFunc) => {
return (_0: unknown, _1: unknown, ...args: Parameters<TFunc>): ReturnType<TFunc> => {
return fetch(...args);
Expand Down

0 comments on commit 1f28702

Please sign in to comment.