不能从apollo-client导入createBatchingNetworkInterface

我正在尝试将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'所需的对象。

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

这听起来像是你正在使用阿波罗客户端2.0。你应该降级到旧版本(1.9.3),以继续使用networking接口,包括批处理。

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