【问题标题】:cant import createBatchingNetworkInterface from apollo-client无法从 apollo-client 导入 createBatchingNetworkInterface
【发布时间】:2018-04-17 00:33:44
【问题描述】:

我正在尝试将 graphql 与我的 vue 项目集成。 我正在遵循这些说明:https://github.com/Akryum/vue-apollo

我已按要求安装了 npm 'apollo-client',但由于某种原因我无法导入 'createBatchingNetworkInterface'。

这是我的 main.js 文件:

import Vue from 'vue'
import { ApolloClient, createBatchingNetworkInterface } from 'apollo-client'
import VueApollo from 'vue-apollo'
import App from './App'
import router from './router'

这是我的 apollo-client 的 index.d.ts 文件:

export { print as printAST } from 'graphql/language/printer';
export { ObservableQuery, FetchMoreOptions, UpdateQueryOptions, ApolloCurrentResult } from './core/ObservableQuery';
export { WatchQueryOptions, MutationOptions, SubscriptionOptions, FetchPolicy, FetchMoreQueryOptions, SubscribeToMoreOptions, MutationUpdaterFn } from './core/watchQueryOptions';
export { NetworkStatus } from './core/networkStatus';
export * from './core/types';
export { ApolloError } from './errors/ApolloError';
import ApolloClient, { ApolloClientOptions } from './ApolloClient';
export { ApolloClientOptions };
export { ApolloClient };
export default ApolloClient;

我在这里看不到“createBatchingNetworkInterface”所需的对象。

我不知道我在这里做错了什么。

【问题讨论】:

    标签: node.js vue.js graphql apollo apollo-client


    【解决方案1】:

    听起来您正在使用 Apollo Client 2.0。您应该降级到旧版本 (1.9.3) 以继续使用网络接口,包括批处理接口。

    客户端的最新版本改为使用链接。如果您有兴趣,可以查看升级指南here。您仍然可以在 2.0 中使用 apollo-link-batch-http 批量请求。

    【讨论】:

    猜你喜欢
    • 2020-12-06
    • 2021-10-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-26
    • 2021-01-15
    • 2018-04-06
    • 2021-03-18
    • 2022-08-04
    相关资源
    最近更新 更多