setQueryData with infinite query

I am using query factory from TkDodo's blog:
export const teamQueries = {
  all: () => ["teams"],
  lists: () => [...teamQueries.all(), "list"],
  listMemers: (workspaceId: string, searchParams: TeamPageSearch) =>
    infiniteQueryOptions({
      queryKey: [...teamQueries.lists(), workspaceId, "members", searchParams],
      queryFn: ({ pageParam = 0 }) =>
        teamService.getMembers(workspaceId, { ...searchParams, pageParam }),
      initialPageParam: 0,
      getNextPageParam: (lastPage, allPages) => {
        const nextPage =
          lastPage.content.length === DEFAULT_PAGINATION_SIZE ? allPages?.length + 1 : undefined;
        return nextPage;
      },
    }),
};


type TeamPageSearch = {
    textSearch?: string | undefined;
    role?: string | undefined;
    status?: string | undefined;
    sortBy?: string | undefined;
    sortDirection?: string | undefined;
}


After mutating (deleting/editing/adding) a team member I want to update the query data of needed queries. Is there a way to do this, or should I make another key in the factory [...teamQueries.lists(), workspaceId, "members"] that catches all these queries and just invalidate them?
Was this page helpful?