
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
storybook-addon-apollo-client
Advanced tools
Use Apollo Client in your Storybook stories.
yarn
yarn add --dev storybook-addon-apollo-client
npm
npm install -D storybook-addon-apollo-client
import { withApolloClient } from 'storybook-addon-apollo-client';
import MyComponentThatHasAQuery, {
MyQuery,
} from '../component-that-has-a-query';
export default {
title: 'My Story',
decorators: [withApolloClient],
};
export const example = () => <MyComponentThatHasAQuery />;
example.story = {
parameters: {
apolloClient: {
mocks: [
{ request: { query: MyQuery }, result: { data: { viewer: null } } },
],
},
},
};
preview.js
import { withApolloClient } from 'storybook-addon-apollo-client';
import { addDecorator } from '@storybook/react';
import { InMemoryCache } from 'apollo-cache-inmemory';
const cache = new InMemoryCache();
addDecorator(
withApolloClient({
cache,
...// take a look at all the options in https://www.apollographql.com/docs/react/development-testing/testing
// everything that is used in `storybook-addon-apollo-client` is a 1 to 1 mapping of MockedProvider
})
);
if you setup withApolloClient
in preview, it will not need to be added to the decorators
key in each story, consider doing this if you have a lot of stories that depend on Apollo.
Read more about the options available for MockedProvider at https://www.apollographql.com/docs/react/development-testing/testing
To see real world usage of how to use this addon, check out the example app:
FAQs
Use Apollo Client in your Storybook stories.
The npm package storybook-addon-apollo-client receives a total of 85,269 weekly downloads. As such, storybook-addon-apollo-client popularity was classified as popular.
We found that storybook-addon-apollo-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.