How can I mock `networkError` vs `graphQLErrors` in storybook with apollo?

239 Views Asked by At

I'm using Storybook with an Apollo graphql frontend. The component I'm creating stories for treats the graphql networkError differently from graphQLErrors. In the Storybook apollo client add-on documentation there is an example of mocking an error:

import DashboardPage, { DashboardPageQuery } from '.';

export default {
  title: 'My Story',
};

export const Example = () => <DashboardPage />;

Example.parameters = {
  apolloClient: {
    mocks: [
      {
        request: {
          query: DashboardPageQuery,
        },
        error: new Error('This is a mock network error'),
      },
    ],
  },
};

But this is always treated as a networkError as far as I can tell. Is there a way to create separate mock responses for graphQLErrors and networkError?

0

There are 0 best solutions below