]>
git.r.bdr.sh - rbdr/forum/blob - src/stores/apollo.js
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
= {} }) {
17 const handleError = function (error
) {
26 client
.watchQuery({ query
, variables
}).subscribe((result
) => {
29 const error
= new ApolloError({ graphQLErrors: result
.errors
});
30 return handleError(error
);
35 data: result
.data
[key
],
38 }, (error
) => handleError(error
));