1.1.8 • Published 1 year ago

@r26d/absinthe-apollo-link v1.1.8

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@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 "@r26d/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

createAbsintheApolloLink

Creates a terminating ApolloLink to request operations using given AbsintheSocket instance

Parameters

  • absintheSocket
  • onError
  • onStart

References

License

MIT :copyright: r26D LLC

1.1.1

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

0.3.0

1 year ago

0.3.6

1 year ago

0.2.1

2 years ago

0.2.0

2 years ago

0.2.2

2 years ago

0.1.2

2 years ago

0.1.0

4 years ago

0.0.14

4 years ago

0.0.12

4 years ago