aboutsummaryrefslogtreecommitdiff
path: root/src/stores/forums.js
diff options
context:
space:
mode:
authorRuben Beltran del Rio <ruben@unlimited.pizza>2021-03-14 22:41:16 +0100
committerRuben Beltran del Rio <ruben@unlimited.pizza>2021-03-14 22:41:16 +0100
commit18ced3bfaff8ca40edb1a96e631ba1553a3a7a6d (patch)
tree450ee3c84e7400e99ba30261e705b2db619d9bcf /src/stores/forums.js
parentc1bc5993a694f6fd047a3881351827058042483b (diff)
Add stores for GraphQL data:
Diffstat (limited to 'src/stores/forums.js')
-rw-r--r--src/stores/forums.js36
1 files changed, 2 insertions, 34 deletions
diff --git a/src/stores/forums.js b/src/stores/forums.js
index ade01a7..5cce7ba 100644
--- a/src/stores/forums.js
+++ b/src/stores/forums.js
@@ -1,36 +1,4 @@
-import { ApolloError } from '@apollo/client/core';
-import { readable } from 'svelte/store';
-import { client } from '$config/apollo';
+import { store } from './apollo';
import { GET_FORUMS } from '$data/queries';
-const internals = {
-
- // The exported data structure
-
- initialValue: {
- loading: true,
- data: [],
- error: undefined
- }
-};
-
-export const forums = readable(internals.initialValue, (set) => {
-
- client.watchQuery({ query: GET_FORUMS }).subscribe((result) => {
-
- if (result.errors) {
- const error = new ApolloError({ graphQLErrors: result.errors });
- return set({
- loading: false,
- data: [],
- error
- });
- }
-
- set({
- loading: false,
- data: result.data.forums,
- error: undefined
- });
- });
-});
+export const forums = store({ key: 'forums', query: GET_FORUMS, initialValue: [] });