https://github.com/jumpn/absinthe-phoenix-socket-relay
Absinthe Phoenix Socket Relay
https://github.com/jumpn/absinthe-phoenix-socket-relay
absinthe absinthe-graphql absinthe-phoenix relay relay-modern
Last synced: 3 months ago
JSON representation
Absinthe Phoenix Socket Relay
- Host: GitHub
- URL: https://github.com/jumpn/absinthe-phoenix-socket-relay
- Owner: jumpn
- License: mit
- Created: 2017-10-26T22:52:44.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-01T00:32:39.000Z (almost 8 years ago)
- Last Synced: 2025-06-29T11:16:17.688Z (3 months ago)
- Topics: absinthe, absinthe-graphql, absinthe-phoenix, relay, relay-modern
- Language: JavaScript
- Homepage:
- Size: 146 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# @jumpn/absinthe-phoenix-socket-relay
> Absinthe Phoenix Socket Relay
- [Installation](#installation)
- [Using npm](#using-npm)
- [Using yarn](#using-yarn)
- [Examples](#examples)
- [API](#api)
- [createFetcher](#createfetcher)
- [createSubscriber](#createsubscriber)
- [isSubscribed](#issubscribed)
- [References](#references)
- [License](#license)## Installation
### Using [npm](https://docs.npmjs.com/cli/npm)
$ npm install --save @jumpn/absinthe-phoenix-socket-relay
### Using [yarn](https://yarnpkg.com)
$ yarn add @jumpn/absinthe-phoenix-socket-relay
## Examples
- **relay-environment.js**
```javascript
// @flowimport {createFetcher, createSubscriber} from "@absinthe-phoenix-socket-relay";
import {Environment, Network} from "relay-runtime";import absintheSocket from "./absintheSocket";
export default new Environment({
network: Network.create(
createFetcher(absintheSocket),
createSubscriber(absintheSocket)
),
store: new Store(new RecordSource())
});
```## API
### createFetcher
Creates a Fetcher (Relay FetchFunction) using the given AbsintheSocket
instance**Parameters**
- `absintheSocket` **AbsintheSocket**
- `onError` **function (error: [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)): any**Returns **FetchFunction**
### createSubscriber
Creates a Subscriber (Relay SubscribeFunction) using the given AbsintheSocket
instance**Parameters**
- `absintheSocket` **AbsintheSocket**
- `onRecoverableError` **function (error: [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)): any**Returns **SubscribeFunction**
### isSubscribed
Returns a promise that resolves to `true` in case subscription of given
disposable has started or to `false` otherwise**Parameters**
- `disposable` **Disposable**
Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)>**
## References
- [Absinthe Phoenix Socket](https://github.com/jumpn/absinthe-phoenix-socket)
- **Relay**
- [Environment](https://facebook.github.io/relay/docs/relay-environment.html)
- [NetworkLayer](https://facebook.github.io/relay/docs/network-layer.html)
- [FetchFunction](https://github.com/facebook/relay/blob/master/packages/relay-runtime/network/RelayNetworkTypes.js#L79)
- [SubscribeFunction](https://github.com/facebook/relay/blob/master/packages/relay-runtime/network/RelayNetworkTypes.js#L93)## License
[MIT](LICENSE.txt) :copyright: **Jumpn Limited** / Mauro Titimoli (mauro@jumpn.com)