timhall / svelte-apollo

Svelte integration for Apollo GraphQL
MIT License
947 stars 68 forks source link

refetch doesn't seem to work as expected #37

Closed physcopanda closed 4 years ago

physcopanda commented 4 years ago

I'm trying to refetch automatically whenever variables change - however I always have to run my log function to force a refetch. Can anyone point me in the right direction here? Sorry I'm a bit new to Svelte so hopefully this is just me missing something basic.

let start_date = "2020-01-01"; let end_date = "2020-12-31"; let take = 30; let skip = 0; const scheduleMvFeed = query(client, {query: Schedule, variables: {start_date, end_date, skip, take}});

// schedule is refetched whenever dates change $: scheduleMvFeed.refetch({start_date, end_date, skip, take});`

function log() { console.log(take, skip); scheduleMvFeed.refetch({start_date, end_date, skip, take}); }

physcopanda commented 4 years ago

OK - I found my newbie mistake! I had my script block marked as a module! Should have paid more attention, it's in the docs right here