Skip to content

Fix utilsForInfinite.generateFetcher method #231

Open
@jeemyeong

Description

@jeemyeong

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions