我想手动编辑缓存中的一些数据。
如何直接从Vue组件的方法在vue-apollo中 //Load libraries
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const firebase = require("firebase");
const stripe = require('stripe')(functions.config().stripe.token)
const SpotifyWebApi = require('spotify-web-api-node');
//Initialize app
const APP = {
apiKey: "my-API-Key",
authDomain: "My domain auth",
databaseURL: "my databse url",
storageBucket: "my bucket",
messagingSenderId: "my messenger ID"
}
//The Client Credential Flow for Spotify API
const spotifyApi = new SpotifyWebApi({
clientId: 'My cliend ID',
clientSecret: 'My-secret-Key'
});
// Retrieve an access token for Spotify.
spotifyApi.clientCredentialsGrant().then(function (data) {
console.log('All data Spotify API: ' + data.body )
console.log('The access token expires in ' + data.body['expires_in']);
console.log('The access token is ' + data.body['access_token']);
// Save the access token so that it's used in future calls
spotifyApi.setAccessToken(data.body['access_token']);
}, function (err) {
console.log('Something went wrong when retrieving an access token', err);
})
firebase.initializeApp(APP);
admin.initializeApp(APP)
和readQuery()
?我正在寻找类似writeQuery()
的方法,但这种方法无效。我从哪里获得this.$apollo.readQuery(...)
实例?
我是指store
方法中的商店实例,例如update()
。
答案 0 :(得分:3)
在组件内部,您可以获取$this.apollo.provider.defaultClient
形式的方法
methods: {
async doQuery (my_data) {
const apolloClient = this.$apollo.provider.defaultClient
apolloClient.writeQuery({
query: QUERY,
data: {
data: my_data,
},
})
},