5

I want to edit some data in the cache manually.

How can I readQuery() and writeQuery() in vue-apollo directly from a method of a Vue component? Im looking for something like this.$apollo.readQuery(...), which does not work. Where do I get the store instance from?

I mean the store instance from update() method in e.g. this.$apollo.mutate.

Zezi Reeds
  • 1,286
  • 1
  • 16
  • 29

1 Answers1

8

Inside a component you can grab the methods from this.$apollo.provider.defaultClient

  methods: {
    async doQuery (my_data) {
      const apolloClient = this.$apollo.provider.defaultClient
      apolloClient.writeQuery({
        query: QUERY,
        data: {
          data: my_data,
        },
      })
    },
Community
  • 1
  • 1
calmar
  • 1,930
  • 1
  • 14
  • 15