-const internals = {
-
- // The exported data structure
-
- initialValue: {
- loading: true,
- data: null,
- error: undefined
- }
-};
-
-export const getForum = function forum(id) {
-
- return readable(internals.initialValue, (set) => {
-
- client.watchQuery({ query: GET_FORUM, variables: { id } }).subscribe((result) => {
-
- if (result.errors) {
- const error = new ApolloError({ graphQLErrors: result.errors });
- return set({
- loading: false,
- data: null,
- error
- });
- }
-
- set({
- loading: false,
- data: result.data.forum,
- error: undefined
- });
- });
- });
-};