Skip to content

Commit

Permalink
Merge pull request #26 from releasy/v0.1.0
Browse files Browse the repository at this point in the history
V0.1.0
  • Loading branch information
felippepuhle authored Nov 1, 2018
2 parents 9d1d745 + 8caeba8 commit 94e3060
Show file tree
Hide file tree
Showing 139 changed files with 11,859 additions and 4,680 deletions.
21 changes: 17 additions & 4 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
{
"presets": ["flow", "env", "react", "stage-0"],
"presets": [
"@babel/preset-react",
"@babel/preset-typescript",
[
"@babel/preset-env",
{
"targets": {
"browsers": ["last 2 versions"]
},
"modules": false
}
]
],
"plugins": [
"transform-runtime",
["relay", {"schema": "test/fixtures/graphql/schema.json"}]
"@babel/plugin-transform-modules-commonjs",
"@babel/plugin-proposal-class-properties",
"relay"
]
}
}
40 changes: 0 additions & 40 deletions .eslintrc

This file was deleted.

11 changes: 0 additions & 11 deletions .flowconfig

This file was deleted.

13 changes: 9 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
.docz
.DS_Store
npm-debug.log
.idea/
.vscode/

node_modules
.idea
coverage
lib
npm-debug.log

__vcr__/
__generated__/
coverage/
lib/
15 changes: 11 additions & 4 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
.docz
.DS_Store
npm-debug.log
.idea/
.vscode/

node_modules
.idea
coverage
docs
npm-debug.log

doczrc.js

__vcr__/
__generated__/
coverage/
docs/
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ install: true
cache: yarn

node_js:
- '6'
- '8'
- '9'
- '10'

install:
- yarn install
Expand All @@ -16,4 +15,4 @@ script:
- yarn test

after_success:
- bash <(curl -s https://codecov.io/bash)
- bash <(curl -s https://codecov.io/bash)
92 changes: 30 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<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
## Installation

With Yarn:

Expand All @@ -30,7 +30,7 @@ npm install --save-dev relay-devtools

## Usage

Using `Releasy` is quite simple, first we need to create an instance of our [Config](docs/classes/Config.md) class:
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';
Expand All @@ -47,7 +47,7 @@ const config = new Config({
});
```

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

```javascript
import { ReleasyProvider } from 'react-releasy';
Expand All @@ -62,77 +62,45 @@ ReactDOM.render(

## Examples

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

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

const MyComponent = ({ error, isFetching, me }) => {
if (error) {
return `Error: ${error.message}`;
}

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

return `My name is ${me.name}`;
}

export default query(
graphql`
query MyComponentMeQuery {
me {
name
}
}
`
)(MyComponent);
```

If you want to implement your own abstraction of [Relay QueryRenderer](https://facebook.github.io/relay/docs/en/query-renderer.html) or even create some [mutations](https://facebook.github.io/relay/docs/en/mutations.html), we can use [withReleasy](docs/hocs/withReleasy.md) to get the `environment`:

```javascript
import React from 'react';
import { QueryRenderer, graphql } from 'react-relay';
import { withReleasy } from 'react-releasy';

const MyComponent = ({ environment }) => (
<QueryRenderer
environment={environment}
query={graphql`
query MyComponentMeQuery {
me {
id
import { Query } from 'react-releasy';

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

if (props) {
return props.me.id;
}

return 'loading';
}}
/>
);
if (isFetching) {
return 'Loading...';
}

export default withReleasy(MyComponent);
return `My name is ${me.name}`;
})}
</Query>
);
}
```

Also, we can get it directly using `getEnvironment`:
Also, we can commit a mutation using `getEnvironment`:

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

const environment = getEnvironment();

const mutation = graphql`
mutation ChangeNameMutation($input: ChangeNameInput!) {
ChangeName(input: $input) {
Expand All @@ -147,7 +115,7 @@ const mutation = graphql`
let tempID = 0;

const commit = (name) => {
return commitMutation(environment, {
return commitMutation(getEnvironment(), {
mutation,
variables: {
input: {
Expand Down
17 changes: 0 additions & 17 deletions docs/README.md

This file was deleted.

14 changes: 14 additions & 0 deletions docs/components/Query.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: Query
menu: Components
route: /components/query
---

import { PropsTable } from 'docz'
import { Query } from '../../src'

# Query

## Properties

<PropsTable of={Query} />
25 changes: 0 additions & 25 deletions docs/components/ReleasyConsumer.md

This file was deleted.

49 changes: 0 additions & 49 deletions docs/components/ReleasyProvider.md

This file was deleted.

Loading

0 comments on commit 94e3060

Please sign in to comment.