Open
Description
Description
The generateFetcher
method in the utilsForInfinite
object does not function correctly. The current implementation expects the id
, fieldName
, and fieldValue
parameters to be passed individually. However, the method's expected usage involves passing these parameters as a single array. This inconsistency causes runtime errors when attempting to use the generateFetcher
method.
Current Behavior (AS-IS)
The existing code incorrectly structures the generateFetcher
method's input, leading to unexpected behavior:
const utilsForInfinite = {
...,
generateFetcher: <Query = unknown, Variables = unknown>(
query: (variables: Variables) => Promise<Query>,
variables?: Variables
) => (
id: string,
fieldName: keyof Variables,
fieldValue: Variables[typeof fieldName]
) => query({ ...variables, [fieldName]: fieldValue } as Variables)
};
Expected Behavior (TO-BE)
The generateFetcher
method should correctly parse its input to match its intended usage by expecting an array of parameters ([id, fieldName, fieldValue]
). This adjustment aligns the method with the expected structure and prevents runtime errors.
const utilsForInfinite = {
...,
generateFetcher: <Query = unknown, Variables = unknown>(
query: (variables: Variables) => Promise<Query>,
variables?: Variables
) => (
[id, fieldName, fieldValue]: [string, keyof Variables, Variables[typeof fieldName]]
) => query({ ...variables, [fieldName]: fieldValue } as Variables)
};
Metadata
Metadata
Assignees
Labels
No labels