Last active
March 13, 2018 13:33
-
-
Save Grantimus9/def692c6bf56b55f3c893f9dd57a0064 to your computer and use it in GitHub Desktop.
The main entry point, app.js, for this example app.
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
// First we import the various pieces of Vue and Apollo. | |
import Vue from 'vue' | |
import { ApolloClient } from 'apollo-client' | |
import { InMemoryCache } from 'apollo-cache-inmemory' | |
import { HttpLink } from 'apollo-link-http' | |
import VueApollo from 'vue-apollo' | |
// Import our main app component, the top-level container for our app. | |
import App from './App.vue' | |
// Create the link the Apollo Client will manage between our frontend client and GraphQL server. | |
// Note that this is setup for development/demo - deployment will require your real URL. | |
const httpLink = new HttpLink({ | |
// You should use an absolute URL here | |
uri: 'http://localhost:4000/graphql', | |
}) | |
// Create the apollo client, with the Apollo caching. | |
const apolloClient = new ApolloClient({ | |
link: httpLink, | |
cache: new InMemoryCache(), | |
connectToDevTools: true, | |
}) | |
// Install the vue plugin for VueApollo | |
Vue.use(VueApollo) | |
const apolloProvider = new VueApollo({ | |
defaultClient: apolloClient, | |
}) | |
// Bootstrap the new Vue app. It grabs onto the div with id="app that we created in the Phoenix HTML. | |
// We pass the apolloProvider instance to it, so our components can all use the same connection. | |
new Vue({ | |
el: '#app', | |
provide: apolloProvider.provide(), | |
render: h => h(App) | |
}) |
Line 38 indeed doesn't work. I had to use the following to make it work:
new Vue({
el: '#app',
provide: apolloProvider.provide(),
render: h => h(App)
})
@marceldegraaf and @glennpjones you're absolutely right - it's been updated, thanks for the note!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that line 38 is incorrect, per this issue. The correct syntax is: