]>
git.r.bdr.sh - rbdr/forum/blob - src/stores/apollo.js
f84a183f4060cb4741d6fc745526cc6bc45bd1cf
1 import { ApolloError
} from '@apollo/client/core';
2 import { readable
} from 'svelte/store';
3 import { client
} from '$/config/apollo';
6 * This is a generic store for use with apollo
9 export const store
= function store({ key
, query
, initialValue
= null, variables
= {} }) {
19 const handleError = function (error
) {
28 client
.watchQuery({ query
, variables
}).subscribe(
32 const error
= new ApolloError({ graphQLErrors: result
.errors
});
33 return handleError(error
);
38 data: result
.data
[key
],
42 (error
) => handleError(error
)