storybook/docs/snippets/svelte/apollo-wrapper-component.with-mock-implementation.ts.mdx
2023-12-06 14:28:38 +00:00

28 lines
556 B
Plaintext

```html
<!-- MockApolloWrapperClient.svelte -->
<script lang="ts">
import { ApolloClient, InMemoryCache } from '@apollo/client';
import { setClient } from 'svelte-apollo';
const mockedClient = new ApolloClient({
uri: 'https://your-graphql-endpoint',
cache: new InMemoryCache(),
defaultOptions: {
watchQuery: {
fetchPolicy: 'no-cache',
errorPolicy: 'all',
},
query: {
fetchPolicy: 'no-cache',
errorPolicy: 'all',
},
},
});
setClient(mockedClient);
</script>
<slot />
```