|
@@ -0,0 +1,43 @@
|
|
|
+import { defineStore } from 'pinia'
|
|
|
+import { print } from 'graphql/language/printer'
|
|
|
+import gql from 'graphql-tag'
|
|
|
+
|
|
|
+// import REST from '@api/rest-axios'
|
|
|
+import GQL from '@api/graphql-axios'
|
|
|
+// import JSONAPI from '@api/json-axios'
|
|
|
+
|
|
|
+import ConcernementFields from '@api/gql/concernement.fragment.gql'
|
|
|
+
|
|
|
+export const ConcernementsStore = defineStore({
|
|
|
+ id: 'concernements',
|
|
|
+ state: () => ({
|
|
|
+ concernements: []
|
|
|
+ }),
|
|
|
+ getters: {
|
|
|
+
|
|
|
+ },
|
|
|
+ actions: {
|
|
|
+ loadConcernements () {
|
|
|
+ console.log('concernements store loadConcernements');
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ const ast = gql`{
|
|
|
+ allconcernements {
|
|
|
+ ...ConcernementFields
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ${ConcernementFields}
|
|
|
+ `
|
|
|
+ console.log('ast', ast);
|
|
|
+ GQL.post('', { query: print(ast) })
|
|
|
+ .then(({ data : { data : { allconcernements } } }) => {
|
|
|
+ console.log('loadconcernements loaded', allconcernements)
|
|
|
+ this.concernements = allconcernements
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ console.warn('Issue with loadConcernements', error)
|
|
|
+ Promise.reject(error)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+})
|