fbredius/storybook

View on GitHub
docs/snippets/svelte/apollo-wrapper-component.with-mock-implementation.js.mdx

Summary

Maintainability
Test Coverage
```html
<!-- MockApolloWrapperClient.svelte -->

<script>
  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>

<div>
  <slot />
</div>
```