-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 getForum = (id) => store({ key: 'forum', query: GET_FORUM, variables: { id } });
+export const getForums = () => store({ key: 'forums', query: GET_FORUMS, initialValue: [] });