Skip to content

improve mutation workflow #2261

Open
Open
@mplemay

Description

@mplemay

Description

Currently, as far as I can tell when data gets mutated, you have to manually update the tanstack query data in order to update the client state.

const { data, error, refetch } = useQuery("get", "/api/test");
const { mutateAsync } = useMutate("patch", "/api/test");

const handleUpdateClick = async () => {
    await mutateAsync({ params: { query: { message: "Message updated by mutate!" } } });
    // optionally refresh, etc.
    refetch();
 };

There should be a clean way to update the query data without additional changes.

Proposal

Either add a parameter, etc. to automatically update the query data.

Extra

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions