Paul Razvan Berg
Paul Razvan Berg

Reputation: 21510

How to re-run local resolvers in React Apollo?

In my queries, I use a blend of remote and local properties, like this:

foo {
  bar
  baz
  qux @client
  quux @client {
    corge
    grault
  }
}

I have resolvers in place for qux and quux, but I'd like to recompute the data once every so often. I thought about writing directly to the cache with cache.writeData and setInterval, but that would a lot of rewriting.

Is there a way to run the resolvers again?

Upvotes: 0

Views: 126

Answers (1)

Greg Brodzik
Greg Brodzik

Reputation: 1817

If you'd like to run the resolvers again on a specific interval, you can pass pollInterval as an option to your graphql HOC or as a prop to your Query component, depending on your implementation. Alternatively, if you would like to requery in response to, for example, a user event, you could invoke the refetch function, which should be accessible via props. For additional info see docs here.

Upvotes: 1

Related Questions