add graphql deps and minimal example
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
import axios from 'axios'
|
||||
|
||||
export default axios.create({
|
||||
baseURL: window.location.origin + '/api/gql',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,5 @@
|
||||
query TextRef ($id: Int!) {
|
||||
textref (id: $id) {
|
||||
title
|
||||
}
|
||||
}
|
||||
+14
-2
@@ -1,11 +1,23 @@
|
||||
<template>
|
||||
<div class="home">
|
||||
Home
|
||||
{{ text }}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'Home'
|
||||
name: 'Home',
|
||||
|
||||
data () {
|
||||
return {
|
||||
text: null
|
||||
}
|
||||
},
|
||||
|
||||
created () {
|
||||
this.$store.dispatch('GET_TEXT', 1).then(({ data }) => {
|
||||
this.text = data.data.textref
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
+18
-2
@@ -1,11 +1,27 @@
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
|
||||
// import Corpus from './modules/corpus'
|
||||
import api from '@/api'
|
||||
import { print } from 'graphql/language/printer'
|
||||
import TextRef from '@/api/queries/TextRef.gql'
|
||||
|
||||
|
||||
Vue.use(Vuex)
|
||||
|
||||
|
||||
export default new Vuex.Store({
|
||||
modules: {
|
||||
// Corpus
|
||||
},
|
||||
|
||||
state: {
|
||||
},
|
||||
|
||||
mutations: {
|
||||
},
|
||||
|
||||
actions: {
|
||||
'GET_TEXT' ({ state }, id) {
|
||||
return api.post('', { query: print(TextRef), variables: { id } })
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user