Created
October 4, 2018 14:09
-
-
Save smolinari/41f6a1a620ff03caddb6f8d77febf222 to your computer and use it in GitHub Desktop.
The plugin file for Quasar and Vue-Apollo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ApolloClient } from 'apollo-client' | |
import { InMemoryCache } from 'apollo-cache-inmemory' | |
import VueApollo from 'vue-apollo' | |
import fetch from 'node-fetch' | |
import { createHttpLink } from 'apollo-link-http' | |
const httpLink = createHttpLink({ uri: 'http://localhost:4000/graphql', fetch: fetch }) | |
// Create the apollo client | |
const apolloClient = new ApolloClient({ | |
link: httpLink, | |
cache: new InMemoryCache(), | |
connectToDevTools: true | |
}) | |
export const apolloProvider = new VueApollo({ | |
defaultClient: apolloClient, | |
errorHandler ({ graphQLErrors, networkError }) { | |
if (graphQLErrors) { | |
graphQLErrors.map(({ message, locations, path }) => | |
console.log( | |
`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}` | |
) | |
) | |
} | |
if (networkError) { | |
console.log(`[Network error]: ${networkError}`) | |
} | |
} | |
}) | |
export default ({ app, Vue }) => { | |
Vue.use(VueApollo) | |
app.apolloProvider = apolloProvider | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment