Skip to content

Tanstack Query for Svelte 5 does not rerender when adding a dependency variable #7227

Open
@Boniqx

Description

@Boniqx

Describe the bug

Issue Description:

Problem:
When utilizing the createInfiniteQuery client to manage infinite queries, there is an issue with updating the query despite the addition of a dependency variable in the query key.

Steps to Reproduce:

Initialize a query using createInfiniteQuery.
Define a queryKey that includes generic variables.
Implement the queryFn function to handle data retrieval based on certain conditions.
Attempt to update the query based on changes in the dependency variable within the queryKey.

Actual Behavior:
Despite adding the dependency variable to the queryKey, the query does not update as expected when the variable changes.

Code Snippet:

javascript

let query = createInfiniteQuery({
  queryKey: ['Resource', dependencyVariable],
  queryFn: async ({ pageParam }) => {
    // Implementation omitted for brevity
  },
  getNextPageParam(lastPage) {
    // Implementation omitted for brevity
  },
  initialPageParam: null as string | null | undefined,
  initialDataUpdatedAt: () => Date.now(),
});

Environment:

Framework/Libraries: SVELTE 5
Possible Solutions:

Review the implementation of createInfiniteQuery to ensure proper handling of dependency variables.
Check for any inconsistencies or errors in the query key setup.
Consider alternative approaches for managing infinite queries that may better accommodate dynamic updates.

Your minimal, reproducible example

I have added an example code below

Steps to reproduce

Steps to Reproduce:

Initialize a query using createInfiniteQuery.
Define a queryKey that includes generic variables.
Implement the queryFn function to handle data retrieval based on certain conditions.
Attempt to update the query based on changes in the dependency variable within the queryKey.
Expected Behavior:
The query should update accordingly when there are changes in the dependency variable included in the queryKey.

Expected behavior

Expected Behavior:
The query should update accordingly when there are changes in the dependency variable included in the queryKey.

How often does this bug happen?

Every time

Screenshots or Videos

test

Platform

Any platform

Tanstack Query adapter

None

TanStack Query version

@tanstack/svelte-query

TypeScript version

5.4.3

Additional context

Additional Context:
This issue impacts the ability to dynamically update queries based on changing dependency variables, hindering the functionality of the application.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions