ApolloClient userQuery networkStatus won't change when calling refetch outside of useEffect while having relayStylePagination

Viewed 64

I've defined my query field to have relay style pagination:

import { InMemoryCache } from '@apollo/client';
import { relayStylePagination } from '@apollo/client/utilities';

const cache = new InMemoryCache({
  typePolicies: {
    Query: {
      fields: {
        customers: relayStylePagination(),
      },
    },
  },
});

I also have enabled notifyOnNetworkStatusChange in my useQuery options

notifyOnNetworkStatusChange: true

When I do this apollo doesn't refetch new data when variables of the query change so I have to manually call the refetch function with the new variables and when I put my refetch function in an useEffect hook it works as intended and it changes the networkStatus from 7 to something else but when I call the refetch outside an useEffect it refetches the data but it doesn't change the networkStatus. Anyone knows why this happens ?

0 Answers
Related