Skip to content

Instantly share code, notes, and snippets.

@Akryum
Last active September 30, 2019 11:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Akryum/bb05ad75ed79030ca8c91dea08cc5a63 to your computer and use it in GitHub Desktop.
Save Akryum/bb05ad75ed79030ca8c91dea08cc5a63 to your computer and use it in GitHub Desktop.
<template>
<div id="app">
<RouteController />
<nav>...</nav>
<router-view/>
</div>
</template>
<script>
export default {
apollo: {
user: {
// ...
}
},
async onBeforeEachRoute (to, from, next) {
await this.$apollo.firstLoad
if (this.user) {
}
next()
}
}
</script>
export function createRouter (apolloProvider) {
const router = new Router()
router.beforeEach(async (to, from, next) => {
const { data: { user } } = await apolloProvider.clients.default.query({
// ...
})
if (user) {
}
next()
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment