Working connection to app sync

This commit is contained in:
Ben Ramey
2018-05-26 18:27:46 -05:00
committed by benjaminramey
parent d7330814b6
commit 3e817a771e
5 changed files with 60 additions and 3 deletions

View File

@@ -0,0 +1,6 @@
export default {
"graphqlEndpoint": "https://wggm57lvdfd5jne623gpegt53e.appsync-api.us-east-2.amazonaws.com/graphql",
"region": "us-east-2",
"authenticationType": "API_KEY",
"apiKey": "da2-pkudpp62hrdbjntqgr4nmioafm"
}

View File

@@ -15,7 +15,15 @@
"deploy": "aws s3 sync .\\dist\\ s3://lunchrun-public --delete" "deploy": "aws s3 sync .\\dist\\ s3://lunchrun-public --delete"
}, },
"dependencies": { "dependencies": {
"apollo-cache-inmemory": "^1.2.1",
"apollo-client": "^2.3.1",
"apollo-link": "^1.2.2",
"apollo-link-http": "^1.5.4",
"aws-appsync": "^1.0.22",
"graphql": "^0.13.2",
"graphql-tag": "^2.9.2",
"vue": "^2.5.2", "vue": "^2.5.2",
"vue-apollo": "^3.0.0-beta.14",
"vue-router": "^3.0.1" "vue-router": "^3.0.1"
}, },
"devDependencies": { "devDependencies": {

View File

@@ -1,12 +1,17 @@
<template> <template>
<div id="app"> <div id="app" v-if="hydrated">
<router-view/> <router-view/>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
name: 'App' name: 'App',
data: () => ({ hydrated: false }),
async mounted () {
await this.$apollo.provider.defaultClient.hydrated()
this.hydrated = true
}
} }
</script> </script>

View File

@@ -1,12 +1,25 @@
<template> <template>
<div id="start"> <div id="start">
<a href="#">start a lunch run</a> <a href="#">start a lunch run</a>
<ul>
<li v-for="run in runs" :key="run.id">
{{ run.name }}
</li>
</ul>
</div> </div>
</template> </template>
<script> <script>
import gql from 'graphql-tag'
export default { export default {
name: 'Start' name: 'Start',
apollo: {
runs: {
query: gql`query { listRuns(first:10,after:"") { items { id,name }, nextToken } }`,
update: data => data.listRuns.items
}
}
} }
</script> </script>

View File

@@ -3,13 +3,38 @@
import Vue from 'vue' import Vue from 'vue'
import App from './App' import App from './App'
import router from './router' import router from './router'
import VueApollo from 'vue-apollo'
import AWSAppSyncClient from 'aws-appsync'
import appSyncConfig from '../config/AppSync.js'
const appSyncClient = new AWSAppSyncClient({
url: appSyncConfig.graphqlEndpoint,
region: appSyncConfig.region,
auth: {
type: appSyncConfig.authenticationType,
apiKey: appSyncConfig.apiKey
}
},
{
defaultOptions: {
watchQuery: {
fetchPolicy: 'cache-and-network'
}
}
})
const apolloProvider = new VueApollo({
defaultClient: appSyncClient
})
Vue.use(VueApollo)
Vue.config.productionTip = false Vue.config.productionTip = false
/* eslint-disable no-new */ /* eslint-disable no-new */
new Vue({ new Vue({
el: '#app', el: '#app',
router, router,
provide: apolloProvider.provide(),
components: { App }, components: { App },
template: '<App/>' template: '<App/>'
}) })