apollo: {
characters: {
query: CHARACTERS_QUERY,
update: (data) => data.characters.results,
},
},
apollo: {
characters: {
query: CHARACTERS_QUERY,
},
},
computed: {
results() {
return this.characters?.results;
},
},
methods: {
addCharacter(char) {
this.loading = true
try {
this.$apollo.mutate({
mutation: ADD_CHARACTER,
variables: {
character
}
})
} catch {
this.error = true
}
this.loading = false
}
}
const { mutate, loading } = useMutation(ADD_CHARACTER)
return {
mutate,
loading
}
import { createMockClient } from 'mock-apollo-client'
import { DefaultApolloClient } from '@vue/apollo-composable'
const createComponent = () => {
mockClient = createMockClient()
wrapper = shallowMount(AppComponent, {
provide: {
[DefaultApolloClient]: mockClient
}
})
}
import { createMockClient } from 'mock-apollo-client'
import { DefaultApolloClient } from '@vue/apollo-composable'
import todosQuery from '@/graphql/todos.query.gql'
import { todoQueryResponse } from './mockData'
const createComponent = () => {
mockClient = createMockClient()
mockClient.setRequestHandler(
todosQuery,
jest.fn().mockResolvedValue(todoQueryResponse)
)
wrapper = shallowMount(AppComponent, {
provide: {
[DefaultApolloClient]: mockClient
}
})
}