Socket
Socket
Sign inDemoInstall

@activimetrics/socket-apollo-link

Package Overview
Dependencies
22
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @activimetrics/socket-apollo-link

Absinthe Socket Apollo Link


Version published
Maintainers
1
Created

Readme

Source

Absinthe Socket Apollo Link

  • Installation
  • Examples
  • API
  • References
  • License

Installation

Using npm

$ npm install --save @activimetrics/socket-apollo-link

Using yarn

$ yarn add @activimetrics/socket-apollo-link

Examples

  1. 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")
));
  1. 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()
});
  1. 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

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">

References

License

MIT :copyright: Jumpn Limited.

Keywords

FAQs

Last updated on 30 Sep 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc