@absinthe/socket-apollo-link 中文文档教程
@absinthe/socket-apollo-link
Absinthe Socket Apollo Link
Installation
Using npm
$ npm install --save @absinthe/socket-apollo-link
Using yarn
$ yarn add @absinthe/socket-apollo-link
Examples
- 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
创建一个终止 ApolloLink 以使用给定的请求操作 AbsintheSocket 实例
Parameters
absintheSocket
AbsintheSocketonError
$ElementType<Observer<Result, Variables>,"onError"
>onStart
$ElementType<Observer<Result, Variables>,"onStart"
>
References
License
MIT :版权所有:Jumpn Limited。
@absinthe/socket-apollo-link
Absinthe Socket Apollo Link
Installation
Using npm
$ npm install --save @absinthe/socket-apollo-link
Using yarn
$ yarn add @absinthe/socket-apollo-link
Examples
- 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
absintheSocket
AbsintheSocketonError
$ElementType<Observer<Result, Variables>,"onError"
>onStart
$ElementType<Observer<Result, Variables>,"onStart"
>
References
License
MIT :copyright: Jumpn Limited.
更多
你可能也喜欢
- 3d-word-cloud 中文文档教程
- @0x/asset-swapper 中文文档教程
- @1hive/apps-token-request 中文文档教程
- @378q/eslint-config 中文文档教程
- @3yourmind/vue-hooks 中文文档教程
- @42ndstudio/ckeditor5-build-inline-custom 中文文档教程
- @5amcode/sunrise-components 中文文档教程
- @5e7en/dank-twitch-irc 中文文档教程
- @a-a-game-studio/aa-redis-sys 中文文档教程
- @a8k/nunjucks-loader 中文文档教程