reactjsapollo-clientreact-apollo

React Apollo - GraphQL files are not updating/reflecting the changes


I am upgrading my react app to version 18, its still in progress but i am facing a weird behaviour with graphql queries. I am using React Apollo to manage all the frontend store data and graphql macro to load all graphql files. Earlier also every time we make any changes in *.gql. We used to restart the server as those files are not by default watched(hot reload) in CRA config but currently even if i had made any changes, added or removed any fields from gql query/mutations. My application is still trying to load the previous queries. Even restarting the server is not helping. Sometime it works and most of the time it does not work.


Solution

  • I was able to resolve this problem by clearing the cache which was being generated in node_modules. Also i have updated the start script by appending the cache clear command.

    "scripts": {
      "start": "rm -rf ./node_modules/.cache/babel-loader && react-scripts start",
    }
    

    Reference - Clean Create React App's cache when importing graphql files