javascript - 使用 mongoDB 10000 毫秒后,GraphQL 端点缓冲超时
问题描述
我正在尝试使用以下代码将我的 GraphQL 端点与 MongoDB 配对:
const express = require('express');
const { graphqlHTTP } = require('express-graphql');
const schema = require('../schema/schema');
const { MongoClient } = require('mongodb');
const app = express();
const PORT = 3000;
app.use('/graphql', graphqlHTTP({
schema,
graphiql: true
}));
const uri = 'mongodb+srv://<USER_NAME>:<PASSWORD>@mysuperheroes.ucexn.mongodb.net/myFirstDatabase?retryWrites=true&w=majority';
const client = new MongoClient(uri, { useNewUrlParser: true, useUnifiedTopology: true });
client.connect().then(
app.listen(PORT, (err) => {
err ? console.log(err) : console.log('Server started!');
})
);
我怀疑问题出在查询或模式上,很可能存在连接问题,因此附上连接文件和错误消息。我得到的错误:Operation movies.find() buffering timed out after 10000ms
GraphQL 查询:
query {
movies {
name
}
}
解决方案
推荐阅读
- python - 是否可以使用脚本编辑 elasticsearch.yml 文件
- c# - NET5 Windows 服务进程停止后卡在“暂停”状态
- sql - 使用预先聚合的值加入两个表,既不会导致分组错误,也不会导致聚合错误
- entity-framework - Entity Framework 6.4.4 (.NET 4.7.2) - 没有命名的连接字符串
- python - 每次我触摸键盘时 FileSysteEventHandler 和 Observer 都会停止
- algorithm - 查找 DFA 的所有匹配项
- instagram-graph-api - 可以获得所提及评论所有者的用户名吗?
- python - Python Scraping Error - 您可能将元素列表视为单个元素。当您打算调用 find() 时,您是否调用了 find_all()?
- airflow - Sentry 未从 Airflow 记录事件
- javascript - 组件索引不包含默认导出