DEV Community

Discussion on: Apollo state management in Vue application

Collapse
 
austinbv profile image
Austin Vance

Such an awesome response - I just did something similar but I needed to be able to mock in test so I have a service that looks like this

export default class AlertService {
  constructor(private client: ApolloClient<InMemoryCache>) {
    this.client = client;
  }
  // ...
}

Then I inject the real client on Vue.js startup

  Vue.prototype.$alertService = new AlertService(apolloProvider.defaultClient);

Then in a test I can inject a mock.

Thread Thread
 
n_tepluhina profile image
Natalia Tepluhina

Awesome mock! I'm happy the reply was useful :)