@absinthe/socket-apollo-link

中文文档
0.2.1发布于 2019/02/20MITESM + CJS近 30 天下载 4.8万

Absinthe Socket Apollo Link

原始使用文档
文档目录8 节
  1. Installation
  2. Using npm
  3. Using yarn
  4. Examples
  5. API
  6. createAbsintheSocketLink
  7. References
  8. License

@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

  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.

版本与发布记录

@absinthe/socket-apollo-link 共发布 14 个版本,首次发布于 2017/11/08;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.2.1latest2019/02/207 年前
0.2.02018/12/147 年前
0.1.112018/01/038 年前
0.1.102017/11/288 年前
0.1.92017/11/288 年前
0.1.82017/11/108 年前

关于 @absinthe/socket-apollo-link 的常见问题

@absinthe/socket-apollo-link 是什么?

Absinthe Socket Apollo Link

如何安装 @absinthe/socket-apollo-link?

在项目目录运行 npm install @absinthe/socket-apollo-link,或使用 pnpm add / yarn add / bun add。

@absinthe/socket-apollo-link 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/absinthe__socket-apollo-link 是否存在。

@absinthe/socket-apollo-link 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@absinthe/socket-apollo-link 可以商用吗?

@absinthe/socket-apollo-link 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@absinthe/socket-apollo-link 的下载量有多少?

根据 npm 官方下载统计,@absinthe/socket-apollo-link 在 2026/10/05 – 2026/11/03 这 30 天内被下载 48,090 次,日均约 1,603 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@absinthe/socket-apollo-link 还在维护吗?

最新版本 0.2.1 发布于 2019/02/20(7 年前);至今共发布 14 个版本,其中过去 12 个月发布了 0 个;首次发布于 2017/11/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。