Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: useInsertMutation - revalidate config #546

Open
woof-pawsportal opened this issue Dec 13, 2024 · 1 comment
Open

Documentation: useInsertMutation - revalidate config #546

woof-pawsportal opened this issue Dec 13, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@woof-pawsportal
Copy link

Describe the bug
First, thank you for this great project.

If a query contains gte or lte filters, it's unclear that one should use revalidate: true in the config to cause the cache to revalidate. This makes sense that advanced logic like comparing date ranges would not be processable locally, but .eq and other filters will work without revalidate: true.

To Reproduce

    const { data } = useQuery(
        supabase.from('habit_tracking')
            .select('id, timestamp, habit_goal_id')
            .eq('habit_goal_id', id)
            .gte('timestamp', firstDateVisible?.toISODate())
            .lte('timestamp', lastDateVisible?.toISODate())
        ,
        {
            revalidateOnFocus: false,
            revalidateOnReconnect: false,
        }
    );
    console.log(data);
    const { trigger: insert } = useInsertMutation(
        supabase.from('habit_tracking'),
        ['id'],
        'id, timestamp, habit_goal_id',
        {
            onSuccess: () => console.log('fired insert mutation on habit tracking!'),
            // Required for gte and lte in query
            revalidate: true, // If gte & lte filters removed, the cached query is returned with all data
        },

To insert

await insert([{
            timestamp: date.toISO(),
            habit_goal_id: id
        }]);

Expected behavior
Add documentation on what query filters work without revalidate: true in https://github.com/psteinroe/supabase-cache-helpers/blob/main/docs/pages/postgrest/mutations.mdx

Additional context
Wanted to make sure this is expected behaviour before filing PR.

@woof-pawsportal woof-pawsportal added the bug Something isn't working label Dec 13, 2024
@psteinroe
Copy link
Owner

Date values should work. So revalidation should not be required. Can you provide a repro?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants