# react-releasy

> Relay with zero-configuration

Latest version **0.1.0** (published 2018-11-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-releasy
pnpm add react-releasy
yarn add react-releasy
bun add react-releasy
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2018-11-01 |
| First published | 2018-02-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 805.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 96 |
| Maintainers | felippepuhle |
| Keywords | react, relay, graphql |

## Links

- npm: https://www.npmjs.com/package/react-releasy
- Repository: https://github.com/releasy/react-releasy
- Homepage: https://github.com/releasy/react-releasy#readme
- Issues: https://github.com/releasy/react-releasy/issues
- npm.io page: https://npm.io/package/react-releasy

## Dependencies (8)

- [react](https://npm.io/package/react.md) 16.5.2
- [tslib](https://npm.io/package/tslib.md) ^1.9.3
- [graphql](https://npm.io/package/graphql.md) ^14.0.2
- [invariant](https://npm.io/package/invariant.md) ^2.2.4
- [react-relay](https://npm.io/package/react-relay.md) https://github.com/releasy/relay/releases/download/v1.7.0-releasy/react-relay-1.7.0-releasy.tgz
- [string-hash](https://npm.io/package/string-hash.md) ^1.1.3
- [relay-runtime](https://npm.io/package/relay-runtime.md) ^1.7.0
- [local-storage-fallback](https://npm.io/package/local-storage-fallback.md) ^4.1.1

## Alternatives

- [apollo-link-http-common](https://npm.io/package/apollo-link-http-common.md) — 879.0K weekly downloads
- [react-relay](https://npm.io/package/react-relay.md) — 336.8K weekly downloads
- [relay-test-utils](https://npm.io/package/relay-test-utils.md) — 181.6K weekly downloads
- [@vendure/core](https://npm.io/package/@vendure/core.md) — 14.8K weekly downloads
- [@pnpm/deps.graph-sequencer](https://npm.io/package/@pnpm/deps.graph-sequencer.md) — 13.4K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2018-11-01
- 0.0.3 (next) — 2018-03-28
- 0.0.2 — 2018-02-27
- 0.0.1 — 2018-02-16

## README

<h1 align="center">
  <img src="https://avatars2.githubusercontent.com/u/36305983?s=400&u=b5b74ead3bce6d56e6aba796e4a0830f6f54f50a&v=4" width="24" />
  Releasy
</h1>

<p align="center">Relay with zero-configuration.</p>

<p align="center">
  <a href="https://travis-ci.org/releasy/react-releasy"><img src="https://travis-ci.org/releasy/react-releasy.svg?branch=master"></a>
  <a href="https://codecov.io/gh/releasy/react-releasy"><img src="https://img.shields.io/codecov/c/github/releasy/react-releasy.svg"></a>
  <a href="https://github.com/airbnb/javascript"><img src="https://img.shields.io/badge/code%20style-airbnb-green.svg"></a>
  <a href="https://github.com/releasy/react-releasy/issues"><img src="https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat"></a>
</p>

## Installation 

With Yarn:

```
yarn add react-releasy
yarn add --dev relay-devtools
```

or with NPM:

```
npm install --save react-releasy
npm install --save-dev relay-devtools
```

## Usage

Using `Releasy` is quite simple, first we need to create an instance of our [Config](/core/config) class:

```javascript
import { Config, InMemoryCache, Link } from 'react-releasy';

const link = new Link({
  url: 'https://yourserveraddress.com/graphql',
});

const cache = new InMemoryCache();

const config = new Config({
  link,
  cache,
});
```

Then we need to wrap the application with a [ReleasyProvider](/components/releasy-provider):

```javascript
import { ReleasyProvider } from 'react-releasy';

ReactDOM.render(
  <ReleasyProvider config={config}>
    <MyApplication />
  </ReleasyProvider>,
  document.getElementById('root'),
);
```

## Examples

Let's start making a simple [Query](/components/query):

```javascript
import { graphql } from 'react-relay';
import { Query } from 'react-releasy';

const MyComponent = () => {
  return (
    <Query
      query={graphql`
        query MyComponentMeQuery {
          me {
            name
          }
        }
      `}
    >
      {({ me, isFetching, error }) => {
        if (error) {
          return `Error: ${error.message}`;
        }

        if (isFetching) {
          return 'Loading...';
        }

        return `My name is ${me.name}`;
      })}
    </Query>
  );
}
```

Also, we can commit a mutation using `getEnvironment`:

```javascript
import { graphql, commitMutation } from 'react-relay';
import { getEnvironment } from 'react-releasy';

const mutation = graphql`
  mutation ChangeNameMutation($input: ChangeNameInput!) {
    ChangeName(input: $input) {
      me {
        id
        name
      }
    }
  }
`;

let tempID = 0;

const commit = (name) => {
  return commitMutation(getEnvironment(), {
    mutation,
    variables: {
      input: {
        name,
        clientMutationId: tempID++,
      },
    },
  });
};

export default { commit };
```

That's all! You can start to do whatever you want and show to the world the power of Relay.

## Documentation

See more documentation [here](docs).

## License

MIT © [Felippe Rodrigo Puhle](http://github.com/felippepuhle)

---
_Source: https://npm.io/package/react-releasy · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
