Skip to content

Instantly share code, notes, and snippets.

@jonnysamps
Last active February 25, 2021 16:17
Show Gist options
  • Save jonnysamps/f518cd56ba6e554a43329392204d0c71 to your computer and use it in GitHub Desktop.
Save jonnysamps/f518cd56ba6e554a43329392204d0c71 to your computer and use it in GitHub Desktop.
Apollo Client Best Practices - 6
const query = gql`...`;
const watchQuery = apollo.watchQuery({ query });
watchQuery.valueChanges
.pipe(
map(result => result.data)
)
.subscribe(() => {
// ...
});
// Can set it up to poll or just call it when needed.
setInterval(() => watchQuery.refetch(), REFRESH_INTERVAL);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment