Vue-apollo update data problem

async getUserApps(){
      let res=await this.$apollo.query({query:userApps});
      this.apps=res.data.userApps;
    }
    submitForm(form){
      let res=await this.$apollo.mutate({mutation:updateApp,variables:this.app});
            if(res.data.updateApp){
              this.getUserApps()
              this.$message.success("")
              this.dialogVisible=false;
            }
    }

above is the apollo method for getting data, which is executed when the page is loaded. No problem
. Then I submit the operation of submitForm () to modify the data on the page, and the modification is successful. It is necessary to call the above method again to get the latest data.
but I don"t know what the vue-apollo cache problem is, and what is the problem without initiating a http request to request the latest data at the backend?

after debugging, it is found that the getUserApps method is still executed the second time, but there is no request backend, and the data is returned. The data is old and should be taken directly from the cache. How can we not take the data from the cache for the second time?

Aug.04,2021

let res=await this.$apollo.query({
      query:userApps
      fetchPolicy: 'cache-and-network'
      });

change it like this, or change the global configuration of ApolloClient

//  apollo 
const apolloClient = new ApolloClient({
  link: httpLink,
  cache: new InMemoryCache(),
  connectToDevTools: true,
  defaultOptions: {
    watchQuery: {
      fetchPolicy: 'cache-and-network'
    },
    query: {
      fetchPolicy: 'cache-and-network'
    }
  }
})

fetchPolicy= "no-cache"
I also had this problem when I used react. Check this property of Query


are you sure there is no request? Does the Network of the development tool see no request?
if there is no request, post the code a little bit so that you can have a look at it.

Menu