Absinthe Socket Apollo Link
npm install pluralsh-absinthe-socket-apollo-link> Absinthe Socket Apollo Link
$ npm install --save dherault-absinthe-socket-apollo-link
$ yarn add dherault-absinthe-socket-apollo-link
1. Create AbsintheSocketLink (absinthe-socket-link.js)
``javascript
// @flow
import * as AbsintheSocket from "@absinthe/socket";
import {createAbsintheSocketLink} from "@absinthe/socket-apollo-link";
import {Socket as PhoenixSocket} from "phoenix";
export default createAbsintheSocketLink(AbsintheSocket.create(
new PhoenixSocket("ws://localhost:4000/socket")
));
`
2. Send all the operations using AbsintheSocketLink
`javascript
// @flow
import ApolloClient from "apollo-client";
import {InMemoryCache} from "apollo-cache-inmemory";
// see example 1
import absintheSocketLink from "./absinthe-socket-link";
const client = new ApolloClient({
link: absintheSocketLink,
cache: new InMemoryCache()
});
`
3. Subscribe using AbsintheSocketLink and send queries and mutations using HttpLink
`javascript
// @flow
import ApolloClient from "apollo-client";
import {createHttpLink} from "apollo-link-http";
import {hasSubscription} from "@jumpn/utils-graphql";
import {InMemoryCache} from "apollo-cache-inmemory";
import {split} from "apollo-link";
// see example 1
import absintheSocketLink from "./absinthe-socket-link";
const link = split(
operation => hasSubscription(operation.query),
absintheSocketLink,
createHttpLink({uri: "/graphql"})
);
const client = new ApolloClient({
link,
cache: new InMemoryCache()
});
`
Creates a terminating ApolloLink to request operations using given
AbsintheSocket instance
#### Parameters
- absintheSocket AbsintheSocket onError
- $ElementType<Observer<Result, Variables>, "onError"> onStart
- $ElementType<Observer<Result, Variables>, "onStart"`>
- Absinthe Phoenix Socket
- Apollo Link
- Apollo Client
- Terminating Links
- Directional Composition
- Http Link
MIT :copyright: Jumpn Limited.