INIT commit

This commit is contained in:
Michal Kváček
2023-05-31 20:44:10 +02:00
commit a3e8917db5
73 changed files with 5405 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
import {ApolloClient, ApolloLink, HttpLink, InMemoryCache} from '@apollo/client/core'
import {createApolloProvider} from "@vue/apollo-option";
const httpLink = new HttpLink({
uri: 'http://localhost:8000/graphql',
credentials: 'include'
})
export const apolloClient = new ApolloClient({
link: ApolloLink.from([httpLink]),
cache: new InMemoryCache(),
connectToDevTools: true,
})
export const apolloWrapper = {
query(query, variables = {}) {
return apolloClient.query({
query: query,
fetchPolicy: 'no-cache',
variables: variables
})
.then((response) => response)
.catch(err => {
console.error("Error during query: ", err)
})
},
mutate(mutation, variables, onUpdate = () => {}) {
return apolloClient
.mutate({
mutation: mutation,
fetchPolicy: 'no-cache',
variables: variables,
update: () => {
onUpdate();
},
})
.then((response) => response)
.catch(err => {
console.error("Error during mutation: ", err);
})
},
}
// @see https://v4.apollo.vuejs.org/migration/
export const apolloProvider = createApolloProvider({
defaultClient: apolloClient,
})