JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q42698F
  • License MIT

Special Apollo Link with Absinthe Support

Package Exports

  • @r26d/absinthe-apollo-link
  • @r26d/absinthe-apollo-link/lib/index.js
  • @r26d/absinthe-apollo-link/src/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@r26d/absinthe-apollo-link) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@r26d/absinthe-apollo-link

Special Apollo Link with Absinthe Support

Installation

Using npm

$ npm install --save @r26d/absinthe-apollo-link

Using yarn

$ yarn add @r26d/absinthe-apollo-link

Examples

  1. Create AbsintheSocketLink (absinthe-socket-link.js)

import * as AbsintheSocket from "@r26d/absinthe-apollo-socket";
import {createAbsintheApolloLink} from "@r26d/absinthe-apollo-link";
import {Socket as PhoenixSocket} from "phoenix";

export default createAbsintheApolloLink(AbsintheSocket.create(
  new PhoenixSocket("ws://localhost:4000/socket")
));
  1. Send all the operations using AbsintheSocketLink

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

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
  • onError
  • onStart

References

License

MIT ©️ r26D LLC