Skip to content

Commit

Permalink
v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
usulpro committed Jan 14, 2020
1 parent 87a5112 commit 49f18f7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Storybook GraphQL kit
# Storybook GraphQL Kit [![npm version](https://badge.fury.io/js/%40focus-reactive%2Fstorybook-graphql-kit.svg)](https://badge.fury.io/js/%40focus-reactive%2Fstorybook-graphql-kit)

[![Storybook](https://raw.githubusercontent.com/UsulPro/storybook-graphql-kit/master/docs/storybook-logo.png)](https://storybook.js.org/)
[![GraphQL](https://raw.githubusercontent.com/UsulPro/storybook-graphql-kit/master/docs/graphql.png)](https://graphql.org/)
Expand Down Expand Up @@ -140,6 +140,10 @@ It does totally the same but in more compact way, especially if you only want to
5. Handles GraphQL requests and renders story only with successfully received data
6. Works fine with any GraphQL endpoint

## Related Addons

- [Storybook Addon GraphCMS](https://github.com/focusreactive/storybook-graphql-kit-graphcms) thin extension with GraphCMS features

## API

You need to pass options to addon. You can pass them directly as story parameters, with `withGraphQL` decorator or with `Query` helper.
Expand Down Expand Up @@ -191,6 +195,34 @@ export const yourStory = ({ graphQlResponse }) => {
`graphQlResponse.columns` and `graphQlResponse.rows` are useful if you creating own tool to display your GraphQL data. Otherwise use `graphQlResponse.result`.


### Authoring Own Addons based on Storybook-GraphQL-Kit

You can use API to extend this addon with your own representations of receiving data.

```js
import { withGraphQL } from '@focus-reactive/storybook-graphql-kit';

const customRenderer = ({ key, value, ind, options }) => {
if (key !== 'featured field') return null;

return {
id: key,
getLabel: () => `${key}`,
getValue: () => value,
// return your custom React component or null for using `getValue`
render: () => <CustomComponent/>,
};
};

export const withYourServiceFeatures = withGraphQL
.addRender(customRenderer)
.addRender(customRenderer1)
.addRender(customRenderer2);

```

See https://github.com/focusreactive/storybook-graphql-kit-graphcms as example of how to extend and create new addon

## Contributing

Any contribution are welcome to this project! Feel free to open an issue or start a PR.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@focus-reactive/storybook-graphql-kit",
"description": "Storybook addon for writing stories in GraphQL",
"version": "0.2.0",
"version": "1.0.0",
"private": false,
"main": "dist/decorator.js",
"dependencies": {
Expand Down

0 comments on commit 49f18f7

Please sign in to comment.