- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我没有任何 UI 框架。只是一个简单的 Nodejs 脚本,我需要在其中查询 GraphQL。
代码:
const ApolloClient = require('apollo-client')
const client = new ApolloClient()
错误信息:
TypeError: ApolloClient is not a constructor
Package.json:
{
...
"dependencies": {
"apollo-client": "^2.4.13",
"graphql": "^14.1.1",
"graphql-tag": "^2.10.1"
},
}
Node :v8.9.4
我在谷歌上搜索了一段时间,人们遇到这个问题主要是因为 ApolloClient 不再在 react-apollo 中。你必须从'apollo-client'导入它
我从 apollo-client
导入为 const ApolloClient = require('apollo-client')
有什么想法吗?谢谢!
最佳答案
如果您正在使用require
,您可以像这样导入它:
const ApolloClient = require('apollo-client').default
或者像这样
const { ApolloClient } = require('apollo-client')
否则,您将导入整个模块,它本身不是构造函数。
关于node.js - ApolloClient 不是构造函数(带有 nodejs 的 apollo-client),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54688108/
我正在使用 react 和 apollo 客户端建立一个新的 typescript 项目。我正在尝试像这样连接客户端: const client = new ApolloClient({ cach
感谢您来到这里!我是 React 和 Apollo 的新手,我会尽力解释我的情况。 现在,我使用 ApolloClient V3 实现了“无限”滚动到我的网站。这个无限卷轴可以看here .尝试时,您
我需要在运行“useQuery”时定义“client”,但我会无限循环。 我写的代码如下: const QueryKTP = gql` query { documents(transact
我的应用程序包含 本质上初始化客户端的组件。 const client = new ApolloClient({ link: new HttpLink({ // ... }), c
我正在尝试使用 TypeScript 创建 ApolloClient,但有一些我无法解决的类型错误。谁能指出我正确的方向该怎么做? 以下是用于创建客户端的示例代码(可与 JavaScript 一起使用
我正尝试使用 Apollo 为我的 Angular 项目连接到 AWSAppSync(Graphql)。 我做了什么: import AWSAppSyncClient from 'aws-appsyn
当 networkStatus 正在运行时,我试图显示预加载器。 我知道每个查询都会返回它自己的 networkStatus,但是在我的应用程序中有很多不同的查询。我想有一种方法可以在全局范围内处理所
我正在尝试使用此身份验证服务器示例来比较现实世界的应用程序,我从中获取一些数据。但自 Apollo Client 以来我无法捕获客户端错误将其自己的异常发送到控制台。 我的示例服务器将输入与“数据库”
因此,我无法在新的Web应用程序中处理内存泄漏。当然,它在本地开发时从未出现过。每隔18小时,运行一个Web客户端的Kubernetes容器将耗尽内存并重新启动。我已经考虑过这些工具,但是不确定哪一个
我正在关注 this tutorial并尝试实现 graphQl。以下行存在问题: const client = new ApolloClient(); 奇怪的是,我在 react-apollo Gi
我有一个有趣的情况。 我想使用 Apollo 本身发起刷新 token 请求(也称为调用突变) 有什么想法,如何实现这样的目标吗? export default new ApolloClient({
我同时使用 ApolloClient来自“apollo-client”和“apollo-boost”库,比如 const client = new ApolloClient({ uri: 'ht
在我的 main.js 中,我有一些代码可以检查是否存在 localStorage 项目。如果有,它将通过中间件向 ApolloClient 设置添加 Authorization header 。 但
我对 react 还比较陌生,似乎无法从上下文中导入 client 变量。我有一个名为 federation.tsx 的文件,其中包含一些代码,我认为这应该是相关部分: const link = cr
我目前正在使用 ApolloClient 连接到 AppSync GraphQL API。这一切都非常适合查询和突变,但我在订阅工作时遇到了一些麻烦。我遵循了 Apollo 文档,我的 App.js
我正在使用 ApolloGraphQL 实现 React 身份验证。 上下文: 在signin.js 中,当用户单击提交按钮并将其设置为本地存储时,我将生成 token 。 然后,我在 App.js
我想禁用缓存或将缓存限制为 24 小时。我的 ApolloClient 只在服务器端运行。 我的环境: apollo-boost 0.4.3 graphql 14.1.1 apollo-link-ba
我正在阅读有关如何使用订阅的 Appsync 文章并找到此链接:https://docs.aws.amazon.com/appsync/latest/devguide/real-time-data.h
我是 NextJS 和 GraphQL 的新手,我正在使用 MERN 堆栈和(NextJS 和 GraphQL)构建一个应用程序。 我只需要澄清一下我是否使用从 getStaticProps(next
我正在使用 ApolloClient 构建一个应用来查询 GraphQL 端点。我希望对普通查询使用“缓存和网络”获取策略,因为此特定策略仅适用于 watchQueries。我真正想要的是以下内容:
我是一名优秀的程序员,十分优秀!