reactjsapolloapollo-clientapollo-cache-inmemory

Apollo Graphql relayStylePagination prevents query to refetch on variables change


When I use relayStylePagination helper funtion in Apollo Client cache type policies, changing the variables passed to the query doesn't call the query again even if I call the refetch function manually. It perfectly does the fetchMore behavior and merges the new data.

My cache field looks like this:

cache: new InMemoryCache({
      typePolicies: {
        Query: {
          fields: {
            inventories: relayStylePagination(),
          },
        },
      },
    })

Solution

  • I needed to manually call refetch while passing the new variables. Still have no clue why adding relay type policy prevents triggering refetch automatically.