0.2.1 • Published 4 years ago
@lukaskl/absinthe_socket-apollo-link v0.2.1
FORKED
This is forked and updated version of @absinthe/socket-apollo-link (of v0.2.1).
This fork simply replaces the following strings globally:
- @absinthe/socket
+ @lukaskl/absinthe_socket@absinthe/socket-apollo-link
Absinthe Socket Apollo Link
Installation
Using npm
$ npm install --save @absinthe/socket-apollo-linkUsing yarn
$ yarn add @absinthe/socket-apollo-linkExamples
- Create AbsintheSocketLink (absinthe-socket-link.js)
// @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")
));- Send all the operations using AbsintheSocketLink
// @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()
});- Subscribe using AbsintheSocketLink and send queries and mutations using HttpLink
// @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()
});API
createAbsintheSocketLink
Creates a terminating ApolloLink to request operations using given AbsintheSocket instance
Parameters
- absintheSocketAbsintheSocket
- onError$ElementType<Observer<Result, Variables>,- "onError">
- onStart$ElementType<Observer<Result, Variables>,- "onStart">
References
License
MIT :copyright: Jumpn Limited.
0.2.1
4 years ago
0.2.1-dev-1
4 years ago