-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
677f88f
commit 9478c8b
Showing
15 changed files
with
5,698 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.docz | ||
.DS_Store | ||
.idea/ | ||
.vscode/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
.docz | ||
.DS_Store | ||
.idea/ | ||
.vscode/ | ||
|
||
node_modules | ||
npm-debug.log | ||
|
||
doczrc.js | ||
|
||
__vcr__/ | ||
__generated__/ | ||
coverage/ | ||
coverage/ | ||
docs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
name: ReleasyProvider | ||
menu: Components | ||
route: /components/releasy-provider | ||
--- | ||
|
||
import { PropsTable } from 'docz' | ||
import { ReleasyProvider } from '../../src' | ||
|
||
# ReleasyProvider | ||
|
||
## Properties | ||
|
||
<PropsTable of={ReleasyProvider} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
name: Cache | ||
menu: Core | ||
route: /core/cache | ||
--- | ||
|
||
# Cache | ||
|
||
A class responsible to store/recover data without needing make any request to the server. | ||
|
||
## Usage | ||
|
||
```javascript | ||
import { InMemoryCache } from 'react-releasy'; | ||
|
||
const cache = new InMemoryCache({ | ||
ttl: 300000, | ||
size: 250, | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
name: Config | ||
menu: Core | ||
route: /core/config | ||
--- | ||
|
||
# Config | ||
|
||
A configuration class. | ||
|
||
## Usage | ||
|
||
```javascript | ||
import { Config, InMemoryCache, Link } from 'react-releasy'; | ||
|
||
const config = new Config({ | ||
link: new Link({ url: 'https://yourserveraddress.com/graphql' }), | ||
cache: new InMemoryCache(), | ||
devTools: true, | ||
networkLogger: true, | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
name: Link | ||
menu: Core | ||
route: /core/link | ||
--- | ||
|
||
# Link | ||
|
||
A class responsible to fetch data from server. | ||
|
||
## Usage | ||
|
||
```javascript | ||
import { Link } from 'react-releasy'; | ||
|
||
const link = new Link({ | ||
url: 'https://yourserveraddress.com/graphql', | ||
fetchTimeout: 30000, | ||
retryDelays: [1000, 3000, 5000, 10000], | ||
headers: {}, | ||
}); | ||
``` | ||
|
||
Also, we can use a function to generate the `headers` object: | ||
|
||
```javascript | ||
import { Link } from 'react-releasy'; | ||
|
||
// this function would get the token inside localStorage or AsyncStorage | ||
import { getToken } from './auth'; | ||
|
||
const link = new Link({ | ||
url: 'https://yourserveraddress.com/graphql', | ||
fetchTimeout: 30000, | ||
retryDelays: [1000, 3000, 5000, 10000], | ||
headers: () => ({ token: getToken() }), | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
name: VCR | ||
menu: Core | ||
route: /core/vcr | ||
--- | ||
|
||
# VCR | ||
|
||
A class able to record and replay fetching results. | ||
|
||
Usefull for testing purpouses, it will record all HTTP requests and replay on the later ones. | ||
|
||
## Usage | ||
|
||
```javascript | ||
import { VCR } from 'react-releasy'; | ||
|
||
const link = new VCR({ | ||
mode: VCR.MODE.AUTO, | ||
url: 'https://yourserveraddress.com/graphql', | ||
}); | ||
``` | ||
|
||
## Why should I use VCR? | ||
|
||
- Faster (no real HTTP requests are made anymore) | ||
- Deterministic (the test will continue to pass, even if you are offline, or if the server goes down for maintenance) | ||
- Accurate (the response will contain the same data you get from a real request) | ||
|
||
## Modes | ||
|
||
- **VCR.MODE.AUTO**: Record on first execution, replay the later ones. | ||
- **VCR.MODE.RECORD**: Record all executions. (Overwrite data) | ||
- **VCR.MODE.REPLAY**: Replay all executions. |
Oops, something went wrong.